If you are using Auto Layout you should not be modifying the frame property at all. The frame is the result of applying the layout constraints, not a “write” property.
I suppose that you will have a constraint setting the x position of your views. Create an IBOutlet
for that constraint, and instead of modifying your frame
, modify the constant
property of the constraint. Then call to layoutIfNeeded
of the view.
Without seeing more about your views, constraints and outlets, I cannot give you final code, but you will end with something like this:
self.leftConstraint.constant = xPos - 100.f;
[self.slidingView setNeedsUpdateConstraints];
[self.slidingView layoutIfNeeded];
My interpretation of what is happening is that setting the image changes the intrinsic size of the image view, which makes the constraints recalculate themselves, snapping everything back to the starting position. As soon as you slide another pixel, your kicks in again, and the frame
property wins again.
Hope it helps.