Mac Developer Library

Developer

QuartzCore Framework Reference CAAnimation Class Reference

Options
Deployment Target:

On This Page
Language:

CAAnimation

CAAnimation is an abstract animation class. It provides the basic support for the CAMediaTiming and CAAction protocols. To animate Core Animation layers or Scene Kit objects, create instances of the concrete subclasses CABasicAnimation, CAKeyframeAnimation, CAAnimationGroup, or CATransition. More...

Import Statement


import QuartzCore @import QuartzCore;

Availability


Available in OS X v10.5 and later.
  • Specifies whether the value of the property for a given key is archived.

    Declaration

    Swift

    func shouldArchiveValueForKey(_ key: String!) -> Bool

    Objective-C

    - (BOOL)shouldArchiveValueForKey:(NSString *)key

    Parameters

    key

    The name of one of the receiver’s properties.

    Return Value

    YEStrue if the specified property should be archived, otherwise NOfalse.

    Discussion

    Called by the object's implementation of encodeWithCoder:. The object must implement keyed archiving.

    The default implementation returns YEStrue.

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Specifies the default value of the property with the specified key.

    Declaration

    Swift

    class func defaultValueForKey(_ key: String!) -> AnyObject!

    Objective-C

    + (id)defaultValueForKey:(NSString *)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.

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Creates and returns a new CAAnimation instance.

    Declaration

    Objective-C

    + (instancetype)animation

    Return Value

    An CAAnimation object whose input values are initialized.

    Import Statement

    Availability

    Available in OS X v10.5 and later.

  • Determines if the animation is removed from the target layer’s animations upon completion.

    Declaration

    Swift

    var removedOnCompletion: Bool

    Objective-C

    @property(getter=isRemovedOnCompletion) BOOL removedOnCompletion

    Discussion

    When YEStrue, the animation is removed from the target layer’s animations once its active duration has passed. Defaults to YEStrue.

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • An optional timing function defining the pacing of the animation.

    Declaration

    Swift

    var timingFunction: CAMediaTimingFunction!

    Objective-C

    @property(strong) CAMediaTimingFunction *timingFunction

    Discussion

    Defaults to nil, indicating linear pacing.

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • delegate delegate Property

    Specifies the receiver’s delegate object.

    Declaration

    Swift

    var delegate: AnyObject!

    Objective-C

    @property(strong) id delegate

    Discussion

    Defaults to nil.

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Called when the animation begins its active duration.

    Objective-C

    - (void)animationDidStart:(CAAnimation *)theAnimation

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Called when the animation completes its active duration or is removed from the object it is attached to.

    Objective-C

    - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag

    Import Statement

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • For animations attached to SceneKit objects, a Boolean value that determines whether the animation is evaluated using the scene time or the system time.

    Declaration

    Swift

    var usesSceneTimeBase: Bool

    Objective-C

    @property BOOL usesSceneTimeBase

    Discussion

    If the value of this property is YEStrue, animation timing is governed by the currentTime property of the view, layer, or custom renderer responsible for drawing the scene. The default value is NOfalse.

    To attach animations to SceneKit objects, see SCNAnimatable Protocol Reference.

    Import Statement

    import SceneKit

    Availability

    Available in OS X v10.8 and later.

  • For animations attached to SceneKit objects, the duration for transitioning into the animation’s effect as it begins.

    Declaration

    Swift

    var fadeInDuration: CGFloat

    Objective-C

    @property CGFloat fadeInDuration

    Discussion

    Use this property to create smooth transitions between the effects of multiple animations. These transitions are especially useful for geometry animations created with external 3D authoring tools.

    For example, the geometry loaded from a scene file for a game character may have associated animations for player actions such as walking and jumping. When the player jumps, if the fade duration is zero, SceneKit abruptly switches from the current frame of the walk animation to the first frame of the jump animation. If the fade duration is greater than zero, SceneKit plays both animations at once during that duration and interpolates vertex positions from one animation to the other, creating a smooth transition.

    To attach animations to SceneKit objects, see SCNAnimatable Protocol Reference.

    Import Statement

    import SceneKit

    Availability

    Available in OS X v10.9 and later.

  • For animations attached to SceneKit objects, the duration for transitioning out of the animation’s effect as it ends.

    Declaration

    Swift

    var fadeOutDuration: CGFloat

    Objective-C

    @property CGFloat fadeOutDuration

    Discussion

    Use this property to create smooth transitions between the effects of multiple animations. These transitions are especially useful for geometry animations created with external 3D authoring tools.

    For example, the geometry loaded from a scene file for a game character may have associated animations for player actions such as walking and jumping. When the player jumps, if the fade duration is zero, SceneKit abruptly switches from the current frame of the walk animation to the first frame of the jump animation. If the fade duration is greater than zero, SceneKit plays both animations at once during that duration and interpolates vertex positions from one animation to the other, creating a smooth transition.

    To attach animations to SceneKit objects, see SCNAnimatable Protocol Reference.

    Import Statement

    import SceneKit

    Availability

    Available in OS X v10.9 and later.

  • For animations attached to SceneKit objects, a list of events attached to an animation.

    Declaration

    Swift

    var animationEvents: [AnyObject]!

    Objective-C

    @property(nonatomic, retain) NSArray *animationEvents

    Discussion

    An array of SCNAnimationEvent objects, each of which adds a timed action to the animation.

    For example, you can create animation events that play sound effects timed to match the footsteps of an animated game character or that add new nodes to the scene when an animation completes.

    To attach animations to SceneKit objects, see SCNAnimatable Protocol Reference.

    Import Statement

    import SceneKit

    Availability

    Available in OS X v10.9 and later.