【问题标题】:Rotation animation of multiple UIButtons, how can animationDidStop know which stopped?多个UIButton的旋转动画,animationDidStop怎么知道哪个停了?
【发布时间】: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


    【解决方案1】:

    使用 CATransition 重写您的方法并使用此问题的解决方案: How to identify CAAnimation within the animationDidStop delegate?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-05
      • 2023-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-06
      • 1970-01-01
      相关资源
      最近更新 更多