Instance Method

initWithDuration:dampingRatio:animations:

Initializes the animator object with spring-based timing information.

Declaration

- (instancetype)initWithDuration:(NSTimeInterval)duration dampingRatio:(CGFloat)ratio animations:(void (^)(void))animations;

Parameters

duration

The duration of the animation, in seconds.

ratio

The damping ratio to apply to the initial acceleration and oscillation. To smoothly decelerate the animation without oscillation, specify a value of 1. Specify values closer to 0 to create less damping and more oscillation.

animations

The block containing the animations. This block has no return value and takes no parameters. Use this block to modify any animatable view properties. When you start the animations, those properties are animated from their current values to the new values using the specified animation parameters.

Return Value

An initialized animator object or nil if the object could not be created.

Discussion

Spring-based animations cause the value of a property to accelerate initially toward its new value and then oscillate around that value until before finally coming to rest on the value. The initial amount of acceleration is proportional to the difference between the start and end values of the property. In other words, the greater the difference between the start and end values, the greater the initial acceleration. The ratio parameter determines the amount of damping applied to the initial acceleration. Lower damping values correspond to less resistance to the acceleration and more oscillation before coming to rest. Higher damping values correspond to more resistance and less oscillation.

The animator object returned by this method begins in the UIViewAnimatingStateInactive state. You must explicitly start the animations by calling the startAnimation method.

See Also

Initializing a Property Animator

- initWithDuration:curve:animations:

Initializes the animator with a built-in UIKit timing curve.

- initWithDuration:controlPoint1:controlPoint2:animations:

Initializes the animator object with a cubic Bézier timing curve.

- initWithDuration:timingParameters:

Initializes the animator object with a custom timing curve object.

+ runningPropertyAnimatorWithDuration:delay:options:animations:completion:

Creates and returns an animator object that begins running its animations immediately.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software