Graphics Reference
In-Depth Information
8
If you want something done right, do it yourself.
Charles-Guillaume Étienne
The previous chapter introduced the concept of implicit animations. Implicit animations
are a straightforward way to create animated user interfaces on iOS, and they are the
mechanism on which UIKit's own animation methods are based, but they are not a
completely general-purpose animation solution. In this chapter, we will look at
explicit
animations, which allow us to specify custom animations for particular properties or create
nonlinear animations, such as a movement along an arbitrary curve.
The first type of explicit animation we will look at is the
property animation
. Property
animations target a single property of a layer and specify a target value or range of values
for that property to animate between. Property animations come in two flavors:
basic
and
keyframe.
Basic Animations
An animation is a change that happens over time, and the simplest form of change is
when one value changes to another, which is exactly what
CABasicAnimation
is designed
to model.
CABasicAnimation
is a concrete subclass of the abstract
CAPropertyAnimation
class,
which in turn is a subclass of
CAAnimation
, the abstract base class for all animation types
supported by Core Animation. As an abstract class,
CAAnimation
doesn't actually do very
much on its own. It provides a timing function (as explained in Chapter 10, “Easing”), a