代码: 1 CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; 2 [animation setDuration:.6]; 3 NSMutableArray *values = [NSMutableArray array]; 4 [values addObject:[NSNumber numberWithFloat:1.0]]; 5 [values addObject:[NSNumber numberWithFloat:1.2]]; 6 [values addObject:[NSNumber numberWithFloat:1.0]]; 7 [values addObject:[NSNumber numberWithFloat:1.1]]; 8 [values addObject:[NSNumber numberWithFloat:1.0]]; 9 [animation setValues:values]; 10 [animation setRemovedOnCompletion:YES]; 11 [animation setAutoreverses:NO]; 12 animation.timingFunction =[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 13 [_animationView.layer addAnimation:animation forKey:@"transform.scale"];
使用CAKeyframeAnimation实现动画
其中_animationView就是要实现动画view
时间: 2024-10-06 17:12:03