CAKeyframeAnimation *animation= [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
animation.values = @[[NSNumber numberWithFloat:1],[NSNumber numberWithFloat:1.38],[NSNumber numberWithFloat:1]];
animation.duration= .28;
animation.autoreverses=NO;
animation.repeatCount=3;
animation.removedOnCompletion=NO;
animation.fillMode=kCAFillModeForwards;
[self.redBagButton.layer addAnimation:animation forKey:@"zoom"];
/*
animationWithKeyPath后面的双引号输入参数类型,下面的values输入参数值,还可以输入节点时间,这是和其他传参不同的地方
*/

本文详细介绍了如何利用Core Animation中的CAKeyframeAnimation类实现iOS应用中按钮的缩放动画效果。通过设置关键帧动画的路径、值、持续时间、重复次数等属性,演示了从初始状态放大到1.38倍再恢复原状的过程。
562





