Skip to content

Instantly share code, notes, and snippets.

@ddribin
Created March 1, 2012 02:42
Show Gist options
  • Save ddribin/1946836 to your computer and use it in GitHub Desktop.
Save ddribin/1946836 to your computer and use it in GitHub Desktop.
Animating with Autolayout
// Find out where the frames will be with the "after" layout
1. Remove the "before" constraints
2. Add the "after" constraints
3. Call [window layoutIfNeeded], to force the frames to update
4. Grab the frames of all the views I want to animate and save them off
// Go back to what the user sees
5. Remove the "after" constraints
6. Add the "before" constraints
7. Call [window layoutIfNeeded], to force the frames to update
(we're now hopefully back to where we started)
8. Setup an animation to move the views to their new frames (via NSViewAnimation or NSAnimationContext)
9. Run the animation
// The views should already be where the "after" layout thinks they should be
10. Remove the "before" constraints
11. Add the "after" constraints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment