1
votes

I have an UIImageView object which is goes on and off screen at the touch of a UIButton, and I'm doing that by changing it's NSLayoutConstraints. I have successfully animated that 'movement' using the following code:

    self.addY.constant = 44.0f;
    [self.addingScreen setNeedsUpdateConstraints];
    [UIView animateWithDuration:0.50f animations:^{
        [self.addingScreen layoutIfNeeded];
    }];

where addY is the constraint to the top of the screen and addingScreen is my UIImageViewobject. My problem is that I have a series of objects with vertical spacing constraints to addingScreen, and I wanted them to slide along with it. What happens tho, is that those objects instantaneously move to their final frame while the UIImageView slowly follows in the 0.5seconds I set in code. How do I get those objects to move along with the UIImageView? thanks for the help :)

1
Have you tried calling layoutIfNeeded on the closest common parent of all of the related views?Rob

1 Answers

4
votes

I guess you should call layoutIfNeeded also to other views that you want to move. For example try calling [self.view layoutIfNeeded] in animateWithDuration block