我有一个正方形的图像,我知道如何使它旋转。动画旋转......然后停下来......然后再旋转......等等。如何让图像旋转(动画)
我刚才是一个基本的旋转,但并不像上面的GIF:
extension UIView {
func rotate360Degrees(duration: CFTimeInterval = 3) {
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation")
rotateAnimation.fromValue = 0.0
rotateAnimation.toValue = CGFloat(M_PI * 2)
rotateAnimation.isRemovedOnCompletion = false
rotateAnimation.duration = duration
rotateAnimation.repeatCount=Float.infinity
self.layer.add(rotateAnimation, forKey: nil)
}
}
有什么想法就如何做到这一点?
哇,这很快,它完美的作品!非常感谢 - 如果你只知道我非常感谢帮助!你是最好的 : ) – JEL