When I try to set animation.fillMode = kCAFillModeForwards
Xcode can't compile and display an error. "Use of unresolved identifier 'kCAFillModeForwards'".
I've already used this in previous projects without any issues, did somebody already encountered this behaviour?
func animateGradient() {
currentGradient += 1
let animation = CABasicAnimation(keyPath: Animation.keyPath)
animation.duration = animationDuration
animation.toValue = currentGradientSet()
animation.fillMode = kCAFillModeForwards
animation.isRemovedOnCompletion = false
animation.delegate = self
gradient.add(animation, forKey: Animation.key)
}
That constant has been removed in favor of a forwards
property on the CAMediaTimingFillMode
type. As of Swift 4.2 the same thing is written as:
animation.fillMode = .forwards
That said, the combination of a forward fill mode and not removing the animation when it completes is often misused in an attempt to make an animation "stick"/"remain". Unless you are animating the removal of a layer, a cleaner solution is to update the layer to the new value and add an animation—which is removed when it completes—to transition from the previous value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With