iOS

Animating Autolayout Constraints

As described in Apple Autolayout Guide, your UIView animation block should look like this:

1
2
3
4
5
6
7
[containerView layoutIfNeeded]; // Ensures that all pending layout operations have been completed
[UIView animateWithDuration:1.0 animations:^{
  // Make all constraint changes here
  // For example:
  someViewConstraint.constant = 80;
  [containerView layoutIfNeeded]; // Forces the layout of the subtree animation block and then captures all of the frame changes
}];

Comments