I have following simple nested animation code intended for transition as in the attached image.
[UIView animateWithDuration:2.0f animations:^{
CGRect frame = self.label.frame;
frame.origin.y += 100;
self.label.frame = frame;
} completion:^(BOOL finished) {
[UIView animateWithDuration:2.0f animations:^{
self.button.transform = CGAffineTransformMakeRotation(M_PI);
}completion:^(BOOL finished) {
//
}];
}];
The view layout is defined in XIB file with auto layout. As IB automatically puts it, it has vertical constraint on both button and label.
In this case, the transition goes not as depicted in the attached image. It goes from State1 to State2, but goes back to State1 briefly and then goes to State3.
What I figured is that this is caused by the vertical constraint of the label. As I programmatically removed the constraint in before the animation, the animation started working as intended.
[self.view removeConstraint:self.labelConstraint];
What I want to know is if this is the correct way to do it. Some post suggests that removing constraint sometimes causes unpredicted behavior due to insufficient constraints to determine layout.