CAAnimation 动画之循环转动

CAAnimation 之属性 isRemovedOnCompletion 要设置为 false ,才能不停地循环转动

    /* 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)
    }

你可能感兴趣的:(CAAnimation 动画之循环转动)