Graphics Reference
In-Depth Information
From Basic Animation to Keyframe Animation
Although a basic animation requires you to specify only the start and stop value and/or
by value, keyframe animation enables you specify
.
An array of values for each keyframe. For example, you could use an array of
CGColorRef objects to animate a background color change.
.
An array of values between 0.0 and 1.0 used specify the percentage of the total time
spent between each keyframe.
.
An array of timing function objects ( CAMediaTimingFunction ) used to specify the
pace of each animation process between key frames. These fields specify with one of
the predefined functions, such as kCAMediaTimingFunctionEaseIn , that the anima-
tion should start off slowly and then speed up over time.
Keyframe animation is actually quite simple. First, consider the basic steps you need to
successfully animate a property using keyframe animation:
1. Decide which property you want to animate (for example, frame, background color,
anchor point, position, border width, and so on).
2. In the values field of the animation object, specify the start value, the end value,
and all values in between. These are your keyframes. (See Listing 4-2 for an
example).
3. Specify the full duration of the animation using the duration field.
4. Optionally, specify time durations for the animation that will occur between each
keyframe using the times field. If you don't specify these, Core Animation evenly
divides the duration by the number of values provided in the values field, minus
one.
5. Optionally, specify the timing functions to control animation pacing.
That is all you need to do. You create your animations and add them to your layer. The
-addAnimation call starts the animation.
Keyframe Animation Timing
Core Animation provides a high level of granularity for specifying how your animation
will play. By default, a keyframe animation plays back evenly, dividing the time specified
in the animation's duration field by the total number of keyframes minus one. You
can use the following formula to determine how much time each keyframe of the
animation gets
duration/(number of keyframes - 1)
 
 
Search WWH ::




Custom Search