Recipe: Swapping Views

The UIView animation block doesn’t limit you to a single change. Place as many animation differences as needed in an animation block. Recipe 4-7 combines size transformations with transparency changes to create a more compelling animation. It does this by adding several directives simultaneously to the animation block. This recipe performs five actions at a time. It zooms and fades one view into place while zooming out and fading away another and then exchanges the two in the subview array list.

You’ll want to prepare the back object for its initial animation by shrinking it and making it transparent. When the swap: method first executes, that view will be ready to appear and zoom to size. As with Recipe 4-6, the completion ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.