let key = "rotationAnimation"
if isUpdate
{
let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
let duration: Double = 1.2
let angle: Double = -360
rotationAnimation.byValue = angle / 180.0 * M_PI
rotationAnimation.duration = duration
rotationAnimation.cumulative = true
rotationAnimation.repeatCount = .infinity
rotationAnimation.fillMode = kCAFillModeForwards
rotationAnimation.removedOnCompletion = false
imageView.layer.addAnimation(rotationAnimation, forKey: key)
}
else
{
imageView.layer.removeAnimationForKey(key)
}
參考資料:
http://stackoverflow.com/questions/2306870/is-there-a-way-to-pause-a-cabasicanimation
http://blog.csdn.net/iosevanhuang/article/details/14488239
http://stackoverflow.com/questions/7082578/cabasicanimation-unlimited-repeat-without-huge-valf
留言列表