Instance Method


Add the specified animation object to the layer’s render tree.


func add(_ anim: CAAnimation, forKey key: String?)



The animation to be added to the render tree. This object is copied by the render tree, not referenced. Therefore, subsequent modifications to the object are not propagated into the render tree.


A string that identifies the animation. Only one animation per unique key is added to the layer. The special key kCATransition is automatically used for transition animations. You may specify nil for this parameter.


If the duration property of the animation is zero or negative, the duration is changed to the current value of the kCATransactionAnimationDuration transaction property (if set) or to the default value of 0.25 seconds.

See Also

Layer Animations

func animation(forKey: String) -> CAAnimation?

Returns the animation object with the specified identifier.

func removeAllAnimations()

Remove all animations attached to the layer.

func removeAnimation(forKey: String)

Remove the animation object with the specified key.

func animationKeys() -> [String]?

Returns an array of strings that identify the animations currently attached to the layer.