Graphics Programs Reference
In-Depth Information
Typically, the key path matches the name of the property. For example, a property anima-
tion that will animate a layer's
opacity
property will have a key path of
opacity
.
Sometimes a property whose type is a structure (like
position
, whose type is
CGPoint
) can have each of its members accessed by a key path. (The available options
for this are in the documentation under Core Animation Extensions To Key-Value Cod-
ing.)
However, like
CAAnimation
,
CAPropertyAnimation
is an abstract superclass. To
create an animation object that modifies a property of a layer, you use one of the two con-
crete subclasses of
CAPropertyAnimation
:
CABasicAnimation
and
CAKey-
frameAnimation
. Most of the time you will spend with Core Animation will involve
these two classes.
CABasicAnimation
is the simpler of the two classes. It has two properties:
fromValue
and
toValue
, and it inherits
CAAnimation
's
duration
property.
When a basic animation is added to a layer, the property to be animated is set to the value
in
fromValue
. Over the time specified by
duration
, the value of the property is inter-
Figure 23.3 Interpolating a CABasicAnimation that animates the position of a layer