Instance Method

initWithDampingRatio:initialVelocity:

Initializes the object with the specified damping ratio and velocity vector.

Declaration

- (instancetype)initWithDampingRatio:(CGFloat)ratio initialVelocity:(CGVector)velocity;

Parameters

ratio

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

velocity

The initial velocity and direction of the animation, specified as a unit vector. When applying a spring animation to an existing animation, use this parameter to create a smoother transition between the animations. This parameter is specified as a two-dimensional vector to accommodate view movements. For properties that don’t involve two-dimensional motion, only the magnitude of the vector is considered.

A vector with a magnitude of 1.0 corresponds to an initial velocity that would cover the total animation distance in one second. For example, if the total animation distance is 200 points and the view’s initial velocity is 100 points per second, specify a vector with a magnitude of 0.5.

Return Value

An initialized spring timing parameters object or nil if the object could not be created.

Discussion

This method sets the initial velocity and damping ratio to the provided values.

See Also

Initializing a Spring Timing Parameters Object

- init

Initializes the object with the default timing parameters.

- initWithDampingRatio:

Initializes the timing parameters with the specified damping ratio.

- initWithMass:stiffness:damping:initialVelocity:

Initializes the object with the specified spring stiffness, mass, and damping coefficients.