Extension

CAKeyframeAnimation

This extension adds a convenient variable to CAKeyframeAnimation.


Declaration

public extension CAKeyframeAnimation

Overview

This extension adds a reversed variable to CAKeyframeAnimation that returns a copy of the animation with reversed sets of keyvalues, timing and timing functions.

Topics

Reversing

reversed

A variable that creates a new copy of the current keyframe animation by reversing its keyTimes, values and timingFunctions.

var reversed: CAKeyframeAnimation {
    let reversed = CAKeyframeAnimation(keyPath: keyPath)
    reversed.keyTimes = keyTimes?.reversed().map { NSNumber(floatLiteral: 1.0 - $0.doubleValue) }
    reversed.values = values?.reversed()
    reversed.timingFunctions = timingFunctions?.reversed().map { $0.reversed }
    reversed.duration = duration
    return reversed
}
background Made with Flow.
underscore Made with Flow.
line2 Made with Flow.
line1 Made with Flow.
circle Made with Flow.
hit Made with Flow.

result(s) found for “”.