init(mass:stiffness:damping:initialVelocity:)
Creates a timing parameters object with the specified spring stiffness, mass, damping coefficient, and initial velocity.
Declaration
init(mass: CGFloat, stiffness: CGFloat, damping: CGFloat, initialVelocity velocity: CGVector)Parameters
- mass:
The effective mass of the animated property. This value must be greater than
0. - stiffness:
The spring stiffness coefficient. Higher values correspond to a stiffer spring that yields a greater amount of force for moving objects.
- damping:
The damping force to apply to the spring’s motion. This value is used to compute the damping ratio.
- velocity:
The target property’s initial rate of change at the start of the spring animation. If the target property doesn’t change, specify a vector with
dxanddycomponents of0.For details about how to calculate this velocity, see Initialvelocity.
Return Value
An initialized spring timing parameters object or nil if the object could not be created.
Discussion
The damping ratio for the spring is computed from the formula damping / (2 * sqrt (stiffness * mass)).