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 specified 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.
-
BeginTime
This property is useful in an animation group. It specifies a time for the animation to begin playing in relation to the time of the parent group animation's duration. The default is 0.0. Animation grouping is discussed in the next section, "Animation Grouping."
-
TimeOffset
If a time offset is set, the animation won't actually become visible until this amount of time has elapsed in relation to the time of the parent group animation's duration.
-
RepeatCount
The default is zero, which means that the animation will only play back once. To specify an infinite repeat count, use 1e100f. This property should not be used with repeatDuration.
-
RepeatDuration
This property specifies how long the animation should repeat. The animation repeats until this amount of time has elapsed. It should not be used with repeatCount.