Core Animation学习笔记二:CABasicAnimation
CABasicAnimation:为层的属性提供了简单的插值
//需要改变的属性
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"cornerRadius"];
animation.fromValue=[NSNumber numberWithFloat:0.0f];
animation.toValue=[NSNumber numberWithFloat:40.0f];
//执行时间
animation.duration = 10.0;
//执行次数
animation.repeatCount=2;
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"cornerRadius"];
animation.fromValue=[NSNumber numberWithFloat:0.0f];
animation.toValue=[NSNumber numberWithFloat:40.0f];
//执行时间
animation.duration = 10.0;
//执行次数
animation.repeatCount=2;
[layer addAnimation:animation forKey:@"change"];
CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
//角度转弧度
rotationAnimation.toValue = [NSNumber numberWithFloat:(DEGREES_TO_RADIANS(160))];
rotationAnimation.duration = 1.0f;
//回退动画
rotationAnimation.autoreverses = YES;
//动画开始结束的快慢,设置为加速
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[pinLayer addAnimation:rotationAnimation forKey:@"revItUpAnimation"];