Extension
This extension adds a convenient variable to CAKeyframeAnimation.
public extension CAKeyframeAnimation
This extension adds a reversed
variable to CAKeyframeAnimation
that returns a copy of the animation with reversed sets of keyvalues, timing and timing functions.
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
}
result(s) found for “”.