Bummer! This is just a preview. You need to be signed in with a Treehouse account to view the entire video.
Introduce View Controller Transitions1:02 with Sam Soffes
View controller transitions work with an animation context where you can add subviews from your view controllers. Within the animateTransition method you can perform any animation that is possible using UIView animations. Finally, the method transitionDuration specifies the length of time the transition should execute.
UI View controller transitions are new in seven and they're really great.
Before, doing a custom UI view controller transition was really hard.
Now there's a common interface that makes it
really easy to create transitions and reuse them.
Let's get set up and see how this works.
We have a view controller we want to animate
from and another one we want to animate to.
We actually instruct the system that we want to create a custom transition.
It then creates a transition animation context that manages all of this for you.
It delegates the details of your
transition's animation to your custom transition.
We will need to implement animateTransition to do the
animation and transitionDuration to see how long it should be.
Then when you're done, call transitionEnded,
tell the system, your animation completed.
And that's it.
You can provide animations, do all kinds of great things, like make
custom action sheets, custom alerts, or anything else you can think of.
Let's look at how to add a custom transition to our app.
You need to sign up for Treehouse in order to download course files.Sign up