Currently, I have a Pan Gesture that moves an UIImageView by continuously changing the center of an image using something like this:
if let view = recognizer.view {
view.center = CGPoint(x:view.center.x + translation.x,
y:view.center.y + translation.y)
}
I also want to alter text labels every second (timer) and this resets the moved UIImageView to default constraints because of auto layout format. I've seen that the proper way to move UIImageViews is to change the constraints of the UIImageView and not the center. Is there any way to change the constraints of an UIImageView to fit the current position of the image? I tried using
view.updateConstraints()
but that did not fix it. Ideally, it would behave like the "reset to suggested constraints" option when setting up constraints manually on storyboard, but used in the ViewController Class instead. I'm trying to avoid setting up all the constraints as IBOutlets and editing them like that as I have a lot of images with multiple constraints and multiple Pan Gestures that would need modifying.