CAAnimation 之屬性 isRemovedOnCompletion 要設(shè)置為 false ,才能不停地循環(huán)轉(zhuǎn)動(dòng)
/* When true, the animation is removed from the render tree once its
* active duration has passed. Defaults to YES. */
open var isRemovedOnCompletion: Bool
func startAnimation() {
let anim = CABasicAnimation(keyPath: "transform.rotation")
anim.toValue = 2 * Double.pi
anim.repeatCount = Float.greatestFiniteMagnitude
anim.duration = 10
anim.isRemovedOnCompletion = false
someView.layer.add(anim, forKey: nil)
}