本文转自http://my.oschina.net/u/661032/blog/74280
头文件记得导入#import <QuartzCore/QuartzCore.h>,及加入framework
01 | +( void )exChangeOut:(UIView *)changeOutView dur:(CFTimeInterval)dur{ |
03 | CAKeyframeAnimation * animation; |
04 | animation = [CAKeyframeAnimation animationWithKeyPath:@ "transform" ]; |
06 | animation.duration = dur; |
10 | animation.removedOnCompletion = NO; |
12 | animation.fillMode = kCAFillModeForwards; |
14 | NSMutableArray *values = [NSMutableArray array]; |
16 | [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]]; |
18 | [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]]; |
20 | [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.9)]]; |
22 | [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]]; |
24 | animation.values = values; |
26 | animation.timingFunction = [CAMediaTimingFunction functionWithName: @ "easeInEaseOut" ]; |
28 | [changeOutView.layer addAnimation:animation forKey:nil]; |
其中changeOutView 即为要实现动画的那个view,dur即为动画的时间,调用的时候传入这2个参数即可;