CAAnimation Class Reference
Overview
CAAnimation
is an abstract animation class. It provides the basic support for the CAMediaTiming
and CAAction
protocols.
Tasks
Archiving Properties
Providing Default Values for Properties
Creating an Animation
Animation Attributes
-
removedOnCompletion
property -
timingFunction
property
Getting and Setting the Delegate
-
delegate
property
Animation Progress
-
– animationDidStart:
delegate method -
– animationDidStop:finished:
delegate method
Properties
delegate
Specifies the receiver’s delegate object.
Discussion
Defaults to nil
.
Important: The delegate
object is retained by the receiver. This is a rare exception to the memory management rules described in Advanced Memory Management Programming Guide.
An instance of CAAnimation
should not be set as a delegate of itself. Doing so (outside of a garbage-collected environment) will cause retain cycles.
Availability
- Available in iOS 2.0 and later.
Declared In
CAAnimation.h
removedOnCompletion
Determines if the animation is removed from the target layer’s animations upon completion.
Discussion
When YES
, the animation is removed from the target layer’s animations once its active duration has passed. Defaults to YES
.
Availability
- Available in iOS 2.0 and later.
Declared In
CAAnimation.h
timingFunction
An optional timing function defining the pacing of the animation.
Discussion
Defaults to nil
, indicating linear pacing.
Availability
- Available in iOS 2.0 and later.
Declared In
CAAnimation.h
Class Methods
animation
Creates and returns a new CAAnimation
instance.
Return Value
An CAAnimation
object whose input values are initialized.
Availability
- Available in iOS 2.0 and later.
Declared In
CAAnimation.h
defaultValueForKey:
Specifies the default value of the property with the specified key.
Parameters
-
key
-
The name of one of the receiver’s properties.
Return Value
The default value for the named property. Returns nil
if no default value has been set.
Discussion
If this method returns nil
a suitable “zero” default value for the property is provided, based on the declared type of the key
. For example, if key is a CGSize object, a size of (0.0,0.0) is returned. For a CGRect
an empty rectangle is returned. For CGAffineTransform
and CATransform3D
, the appropriate identity matrix is returned.
Special Considerations
If key is not a known for property of the class, the result of the method is undefined.
Availability
- Available in iOS 2.0 and later.
Declared In
CAAnimation.h
Instance Methods
shouldArchiveValueForKey:
Specifies whether the value of the property for a given key is archived.
Parameters
-
key
-
The name of one of the receiver’s properties.
Return Value
YES
if the specified property should be archived, otherwise NO
.
Discussion
Called by the object's implementation of encodeWithCoder:
. The object must implement keyed archiving.
The default implementation returns YES
.
Availability
- Available in iOS 4.0 and later.
Declared In
CAAnimation.h
Delegate Methods
animationDidStart:
Called when the animation begins its active duration.
Parameters
-
theAnimation
-
The
CAAnimation
instance that started animating.
Availability
- Available in iOS 2.0 and later.
Declared In
CAAnimation.h
animationDidStop:finished:
Called when the animation completes its active duration or is removed from the object it is attached to.
Parameters
-
theAnimation
-
The
CAAnimation
instance that stopped animating.
flag
-
If
YES
, the animation reached the end of its active duration without being removed.
Availability
- Available in iOS 2.0 and later.
Declared In
CAAnimation.h