Graphics Reference
In-Depth Information
Figure 8.4 Smoothly crossfading between images using CATransition
Implicit Transitions
The fact that CATransition can smoothly cover any changes made to a layer makes it an
ideal candidate for use as a layer action for properties that are otherwise hard to animate.
Apple realizes this, of course, and CATransition is used as the default action when setting
the CALayer contents property. This is disabled for view backing layers along with all
other implicit animation actions, but for layers that you create yourself, this means that
changes to the layer contents image are automatically animated with a crossfade.
We used a CATransition as a layer action in Chapter 7 to animate changes to our layer's
background color. The backgroundColor property can be animated using a normal
CAPropertyAnimation but that doesn't mean you can't use a CATransition instead.
Animating Layer Tree Changes
The fact that CATransition does not operate on specific layer properties means that you
can use it to animate layer changes even when you do not know exactly what has changed.
You can, for example, smoothly cover the reloading of a complex UITableView with a
crossfade without needing to know which rows have been added and removed, or transition
between two different UIViewController instances without needing to know anything
about their internal view hierarchies.
Both of these cases are different from anything we've tried so far because they involve
animating not only changes to a layer's properties but actual layer tree changes—we need
to physically add and remove layers from the hierarchy during the course of the animation.
Search WWH ::




Custom Search