Graphics Reference
In-Depth Information
We need to set two animation properties
for the layer to stay at the destination
position. First is the fill mode. We tell it
to anchor the animation value to the
final value by calling -setFillMode ,
passing it the constant
kCAFillModeForwards . Then we must
tell the animation not to remove itself
from the layer's array of animations
when the animation completes by
calling -setRemovedOnCompletion
passing it NO .
NOTE
This code effectively causes the animation to
finish at the destination, but remember it is
only a visible effect. The internal position
value of the layer is still at the start value.
This becomes problematic if you need to
obtain the current value after your animation
has run.
Useful Animation Properties
You have already discovered all the properties that you can animate in a layer. However,
there are numerous properties available in the animation ( CABasicAnimation ) object that
can give you greater control and enhance your animations.
.
Autoreverses
By setting autoreverses to YES , the animated property returns to its starting value
after it has reached its destination value, but instead of snapping back to the start
value, it animates there.
.
Duration
Duration is a parameter you are quite familiar with at this point. It sets the amount
of time to be taken between the fromValue and toValue of the animation. Duration
is also affected by the speed property.
.
RemovedOnCompletion
The default value for this property is YES , which means that when the animation
has finished its specified duration, the animation is automatically removed from the
layer. This might not be desirable. If you want to animate the property you've speci-
fied again, for example, you want to set this property to NO . That way, the next time
you call -set on the property being animated in the animation, it will use your
animation again rather than the default.
.
Speed
The default value for this property is 1.0. This means that the animation plays back
at its default speed. If you change the value to 2.0, the animation plays back at
twice the default speed. This in effect splits the duration in half. If you specify a
duration of 6 seconds and a speed of 2.0, the animation actually plays back in three
seconds—half the duration specified.
 
Search WWH ::




Custom Search