是否可以为UIView.animate
方法添加引用(或键)?
我有一个闪烁的动画:
public func startBlinking() {
UIView.animate(withDuration: 0.5, delay: 0.0, options: [.autoreverse, .curveEaseInOut, .repeat, .transitionCrossDissolve], animations: { self.alpha = 0.0 }, completion: { completed in self.alpha = 1.0 })
}
我希望能够在不删除我按照以下方式进行的所有动画的情况下停止动画:
public func stopBlinking() {
layer.removeAllAnimations()
}
我知道使用图层动画可以添加关键点:
layer.removeAnimation(forKey: "blinking")
例如。 UIView.animate
方法是否有相似之处?
谢谢