Animate Property Changes in a View
1 2 3 4
NOTE: When this code executes, the specified animations are started immediately on another thread so as to avoid blocking the current thread or your application’s main thread.
Usage of Completion Handler
- Use a completion handler to signal your application that a specific animation has finished.
- Completion handlers are also the way to link separate animations together.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Nesting Animation Blocks
Nested animations are started at the same time as any parent animations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Creating Animated Transitions Between Views
View transitions help you hide sudden changes associated with adding, removing, hiding, or showing views in your view hierarchy. You use view transitions to implement the following types of changes:
- Change the visible subviews of an existing view. You typically choose this option when you want to make relatively small changes to an existing view.
- Replace one view in your view hierarchy with a different view. You typically choose this option when you want to replace a view hierarchy that spans all or most of the screen.
Note: View transitions should not be confused with transitions initiated by view controllers, such as the presentation of modal view controllers or the pushing of new view controllers onto a navigation stack. View transitions affect the view hierarchy only, whereas view-controller transitions change the active view controller as well. Thus, for view transitions, the view controller that was active when you initiated the transition remains active when the transition finishes.
Sampel code for replacing a view with a different view:
1 2 3 4 5 6 7 8 9 10 11 12
Note: In addition to swapping out views, your view controller code needs to manage the loading and unloading of both the primary and secondary views.