Type Method


Returns the default animation that should be performed for the specified key.



+ (id)defaultAnimationForKey:(NSAnimatablePropertyKey)key;



The action name or property specified as a string.

Return Value

The animation to perform. A subclass of CAAnimation.


The NSAnimatablePropertyContainer method consults this class method when its search of the receivers Getting the Animator Proxy dictionary fails to return an animation for key.

An animatable property container should implement this method to return a default animation to be performed for each key that it wants to make auto-animatable, where key usually references a property of the receiver, but can also specify a special animation trigger (NSAnimationTriggerOrderIn or NSAnimationTriggerOrderOut).

A developer implementing a custom view subclass, can enable automatic animation for properties by overriding this method, and having it return the desired default CAAnimation subclass to use for each of the property keys of interest. The override should defer to super for any keys it doesn't specifically handle, facilitating inheritance of default animation specifications. The following is an example of such an implementation.

@implementation MyView
+ (id)defaultAnimationForKey:(NSString *)key {
    if ([key isEqualToString:@"borderColor"]) {
        // By default, animate border color changes with simple linear interpolation to the new color value.
        return [CABasicAnimation animation];
    } else {
        // Defer to super's implementation for any keys we don't specifically handle.
        return [super defaultAnimationForKey:key];

See Also

Managing Animations for Properties


Sets the option dictionary that maps event trigger keys to animation objects.


- animationForKey:

Returns the animation that should be performed for the specified key.