Simple linear calculation between keyframe values.
On This Page
static let linear: CAAnimationCalculationMode
Listing 1 shows how to create a keyframe animation object using linear interpolation.
Creating linearly interpolated keyframes
let keyframeAnimation = CAKeyframeAnimation(keyPath: "position.y")
keyframeAnimation.calculationMode = kCAAnimationLinear
keyframeAnimation.keyTimes = [0, 0.25, 0.5, 0.75, 1]
keyframeAnimation.values = [310, 60, 120, 60, 310]
A layer animated with the keyframe animation created by the code above and with linearly interpolated horizontal movement would describe a path similar to Figure 1.
Tracing the path of an animation using linearly interpolated keyframes