点击的动画效果

func scaleAnimation() {
        let scaleAnim1 = CABasicAnimation(keyPath: "transform")
        scaleAnim1.fromValue = NSValue(CATransform3D: CATransform3DIdentity)
        scaleAnim1.toValue = NSValue(CATransform3D: CATransform3DMakeScale(0.97, 0.97, 1.0))
        scaleAnim1.fillMode = kCAFillModeForwards
        scaleAnim1.duration = 0.2
        scaleAnim1.beginTime = 0
        scaleAnim1.removedOnCompletion = true
        
        let scaleAnim2 = CABasicAnimation(keyPath: "transform")
        scaleAnim2.toValue = NSValue(CATransform3D: CATransform3DIdentity)
        scaleAnim2.fillMode = kCAFillModeForwards
        scaleAnim2.duration = 0.1
        scaleAnim2.beginTime = 0.2
        scaleAnim2.removedOnCompletion = true
        
        let animGroup = CAAnimationGroup()
        animGroup.animations = [scaleAnim1,scaleAnim2]
        animGroup.duration = 0.3
        animGroup.removedOnCompletion = true
        animGroup.delegate = self
        self.layer.addAnimation(animGroup, forKey: "scaleAnimation")
    }

你可能感兴趣的:(点击的动画效果)