【发布时间】:2015-05-16 21:26:46
【问题描述】:
我在下面有这段代码可以将 UIView 旋转 360 度。 是UIView的扩展文件。
extension NSView {
func rotate360Degrees(duration: CFTimeInterval = 0.5, 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)
}
}
点击按钮后,我使用refreshButton.rotate360Degrees() 启动动画。
我想为 NSView 重新创建它,但使用上面的代码似乎无法正常工作。 谢谢
【问题讨论】:
标签: ios macos swift animation nsview