【发布时间】:2014-11-14 10:32:45
【问题描述】:
我正在尝试让四个 UIButton 在 Swift 中旋转。我得到了这个:
import UIKit
extension UIView {
func rotate360Degrees(duration: CFTimeInterval = 1.0, completionDelegate: AnyObject? = nil) {
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation")
rotateAnimation.fromValue = 0.0
rotateAnimation.toValue = CGFloat(M_PI * 2.0)
rotateAnimation.duration = duration
if let delegate: AnyObject = completionDelegate {
rotateAnimation.delegate = delegate
}
self.layer.addAnimation(rotateAnimation, forKey: nil)
}
}
但我需要重复一遍。在我的 UIViewController 中,我使用了 animationDidStop 函数,但我怎么知道四个动画中的哪一个触发了它?它有一个名为 CAAnimation 的参数,但我无法将它与任何东西进行比较。有什么建议吗?
【问题讨论】:
标签: ios animation swift uiview uibutton