美文网首页iOS学习
Swift3顺时针旋转+收缩动画

Swift3顺时针旋转+收缩动画

作者: 浮云千载唯忆君颜 | 来源:发表于2017-01-27 14:08 被阅读342次
    func roundAnimation() {        
            let animationRotation = CABasicAnimation.init()
            animationRotation.keyPath = "transform.rotation.z"
            animationRotation.toValue = NSNumber.init(value: Float(M_PI) * 5)
            animationRotation.duration = 2
            animationRotation.speed = 2
            animationRotation.fillMode = kCAFillModeForwards
            animationRotation.timingFunction = CAMediaTimingFunction.init(name: kCAMediaTimingFunctionEaseInEaseOut)
            circleIV.layer.add(animationRotation, forKey: nil)
            
            let animationScale = CAKeyframeAnimation.init(keyPath: "transform")
            animationScale.duration = 1
            var values = [NSValue]()
            values.append(NSValue.init(caTransform3D: CATransform3DMakeScale(1.0, 1.0, 1.0)))
            values.append(NSValue.init(caTransform3D: CATransform3DMakeScale(0.6, 0.6, 1.0)))
            values.append(NSValue.init(caTransform3D: CATransform3DMakeScale(1.0, 1.0, 1.0)))
            animationScale.values = values
            
            let animationGroup = CAAnimationGroup.init()
            animationGroup.duration = 2
            animationGroup.animations = [animationScale, animationRotation]
            
            circleIV.layer.add(animationGroup, forKey: nil)
        }
    

    相关文章

      网友评论

        本文标题:Swift3顺时针旋转+收缩动画

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