iOS学习

Swift3顺时针旋转+收缩动画

2017-01-27  本文已影响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)
    }
上一篇下一篇

猜你喜欢

热点阅读