向UIView.animate添加引用(或键)

时间:2018-12-03 10:47:11

标签: ios swift animation uiview

是否可以为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方法是否有相似之处?

谢谢

0 个答案:

没有答案