序列帧动画
曾经项目里的一段源码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
UIImageView * activityImageView = [[UIImageView alloc] init]; NSMutableArray *imagesList = [NSMutableArray array]; for (NSInteger i = 1; i < 3; i++) {
NSString *fileName = [NSString stringWithFormat:@"eggplant%i.png",i]; UIImage *image = [UIImage imageNamed:fileName]; [imagesList addObject:image]; } [activityImageView setAnimationImages:imagesList]; [activityImageView setAnimationDuration:0.5];
|
UIView 动画
UIViewAnimation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
|
UIViewAnimationWithBlocks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
|
CoreAnimation
CATransition
继承关系:CATransition -> CAAnimation
1 2 3 4 5 6 7 8
|
CATransition *transition = [CATransition animation]; transition.duration = 0.5; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
|
CAPropertyAnimation
继承关系:CABasicAnimation,CAKeyframeAnimation -> CAPropertyAnimation -> CAAnimation
CABasicAnimation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
CABasicAnimation * animation = [CABasicAnimation animation]; animation.keyPath = @"position.y";
//运动的绝对距离 animation.fromValue = @77; animation.toValue = @455;
//运动的相对距离 // animation.byValue = @222;
animation.duration = 1; //留在最终状态 animation.fillMode = @"forwards"; //防止它被自动移除 animation.removedOnCompletion = NO; animation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.5 :0 :0.9 :0.7]; [testView.layer addAnimation:animation forKey:@"basic"];
|
CAKeyframeAnimation 例一
1 2 3 4 5 6 7 8 9
|
CAKeyframeAnimation * animation = [CAKeyframeAnimation animation]; animation.keyPath = @"position.x"; animation.values = @[@0,@10,@-10,@10,@0]; //指定关键帧动画发生的时间 animation.keyTimes = @[ @0, @(1 / 6.0), @(3 / 6.0), @(5 / 6.0), @1 ]; animation.duration = 0.4; //提前无需设置位置 animation.additive = YES; [testView.layer addAnimation:animation forKey:@"shake"];
|
CAKeyframeAnimation 例二
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
CGRect boundingRect = CGRectMake(-150, -150,300, 300);
CAKeyframeAnimation *orbit = [CAKeyframeAnimation animation]; orbit.keyPath = @"position";
|
CAAnimationGroup 组动画
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; animation.duration = 3.; animation.fromValue = @(0.1); animation.toValue = @(1.);
CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"transform.scale.y"]; animation2.duration = 3.; animation2.fromValue = @(1); animation2.toValue = @(2.); animation2.beginTime = 3.;
CAAnimationGroup *group = [CAAnimationGroup animation]; group.duration = 6.; group.animations = @[animation,animation2]; [testView.layer addAnimation:group forKey:nil];
|
Facebook pop 动画
POPBasicAnimation 基本动画
1 2 3 4
|
POPBasicAnimation *anim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerScaleXY]; anim.toValue = [NSValue valueWithCGPoint:CGPointMake(2.0, 2.0)]; anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; [testView.layer pop_addAnimation:anim forKey:@"Animation"];
|
POPSpringAnimation 弹性动画
1 2 3 4 5 6 7 8 9 10 11 12
|
POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPosition]; anim.fromValue = [NSValue valueWithCGPoint:CGPointMake(60, 350)]; anim.toValue = [NSValue valueWithCGPoint:CGPointMake(60, 150)]; anim.springBounciness = 10; anim.springSpeed = 10;
|
POPDecayAnimation 减速动画
1 2 3 4 5 6 7 8 9 10 11
|
POPDecayAnimation *anim = [POPDecayAnimation animationWithPropertyNamed:kPOPLayerPositionX];
|
UIViewController动画
有时间详细整理下:
http://onevcat.com/2013/10/vc-transition-in-ios7/
http://objccn.io/issue-12-3/
参考文章:
http://objccn.io/issue-12-1/
另外.....
我的愿望是.......
世界和平.........