美文网首页
CAAnimation 动画之循环转动

CAAnimation 动画之循环转动

作者: willokyes | 来源:发表于2018-01-04 20:55 被阅读0次

    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 动画之循环转动

          本文链接:https://www.haomeiwen.com/subject/ntednxtx.html