Graphics Programs Reference
In-Depth Information
The Core Animation code you will write in this exercise will be in TimeViewCon-
troller.m . So import the header from the QuartzCore framework at the top of this file.
#import <QuartzCore/QuartzCore.h>
@implementation TimeViewController
In order to spin the timeLabel , you need an animation object that will apply a
360-degree rotation over time to a layer. So we need to determine four things:
• Which type of animation object suits this purpose?
• What key path handles rotation?
• How long should the animation take to complete?
• What values should the animation interpolate?
To answer the first question, think about the number of keyframes an animation would
need to make a complete revolution. It only needs two: a non-rotated value and a fully-ro-
tated value, so CABasicAnimation can handle this task.
To determine the key path, we use the property of CALayer that deals with rotation. This
property is its transform , the transformation matrix that is applied to the layer when it
draws. The transform of a layer can rotate, scale, translate, and skew its frame. (For
more details, go to Core Animation Extensions To Key-Value Coding in the documenta-
tion.) This exercise only calls for rotating the layer, and, fortunately, you can isolate the
rotation of the transform in a key path ( Figure 23.6 ). Therefore, the key path of the ba-
sic animation will be transform.rotation .
Figure 23.6 Core Animation Extensions to Key-Value Coding documentation
 
Search WWH ::




Custom Search