Initializer

init(duration:controlPoint1:controlPoint2:animations:)

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

Declaration

convenience init(duration: TimeInterval, controlPoint1 point1: CGPoint, controlPoint2 point2: CGPoint, animations: (() -> Void)? = nil)

Parameters

duration

The duration of the animation, in seconds.

point1

The first control point for the cubic Bézier timing curve.

point2

The second control point for the cubic Bézier timing curve.

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

Use this method to create an animator object using a cubic timing curve whose starting point is (0, 0) and whose end point is (1, 1). The point1 and point2 parameters are the control points that define the shape of the resulting Bezier curve. The slope of the curve defines the speed of the animation at different times. Steep slopes cause animations to appear to run faster and shallower slopes cause them to appear to run slower. Figure 1 shows a timing curve where the animations start fast and finish fast but run more slowly through the middle section.

Figure 1

A cubic Bézier timing curve

The animator object returned by this method begins in the UIViewAnimatingState.inactive state. You must explicitly start the animations by calling the startAnimation() method.

See Also

Initializing a Property Animator