[英]Use of unresolved identifier 'kCAFillModeForwards'
When I try to set animation.fillMode = kCAFillModeForwards
Xcode can't compile and display an error. 当我尝试设置animation.fillMode = kCAFillModeForwards
Xcode无法编译并显示错误。 " Use of unresolved identifier 'kCAFillModeForwards'" . “ 使用未解析的标识符'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. 该常量已被删除,有利于CAMediaTimingFillMode
类型的forwards
属性。 As of Swift 4.2 the same thing is written as: 从Swift 4.2开始,同样的事情写成:
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. 除非您要为图层的移除设置动画,否则更清晰的解决方案是将图层更新为新值并添加动画 - 在完成时删除 - 从前一个值转换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.