我有一個正方形的圖像,我知道如何使它旋轉。動畫旋轉......然後停下來......然後再旋轉......等等。如何讓圖像旋轉(動畫)
我剛纔是一個基本的旋轉,但並不像上面的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