Skip to content

CABasicAnimation() constructor ​

The CABasicAnimation() constructor creates an animation with no property specified yet.

In most cases, use CABasicAnimation.animationWithKeyPath(), which creates the animation and specifies the property in one step.

Syntax ​

new CABasicAnimation()

Parameters ​

None.

Return value ​

A new CABasicAnimation. Its keyPath is null; set keyPath before setting fromValue, toValue, or byValue.

Examples ​

js
const fade = new CABasicAnimation();
fade.keyPath = 'opacity';
fade.fromValue = 1;
fade.toValue = 0;

Result: an animation that changes opacity from 1 to 0, the same as CABasicAnimation.animationWithKeyPath('opacity').

Corresponding iOS API ​

[CABasicAnimation animation].

See also ​