序列帧动画

曾经项目里的一段源码:

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];
//0为无限循环
[activityImageView setAnimationRepeatCount:0];
[activityImageView startAnimating];
// [activityImageView stopAnimating];

UIView 动画

UIViewAnimation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//创建一个CGAffineTransform  transform对象
CGAffineTransform transform;
//设置旋转度数
transform = CGAffineTransformRotate(testView.transform,M_PI/6.0);
//动画开始
[UIView beginAnimations:@"rotate" context:nil ];
//动画时常
[UIView setAnimationDuration:2];
//自动反转
// [UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount:3];
//添加代理
[UIView setAnimationDelegate:self];
//获取transform的值
[testView setTransform:transform];
//关闭动画
[UIView commitAnimations];

UIViewAnimationWithBlocks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* Duration 动画持续时间
delay 动画延迟时间
options 动画的节奏控制 */ [UIView animateWithDuration:5 delay:5 options:UIViewAnimationOptionCurveEaseInOut animations:^{
testView.frame = CGRectMake(100, 300, 100, 100);
} completion:^(BOOL finished) { }]; /* Damping 动画的弹力指数
Velocity 弹力的初速度 */ [UIView animateWithDuration:0.5 delay:1 usingSpringWithDamping:0.8 initialSpringVelocity:10 options:0 animations:^{
testView.frame = CGRectMake(100, 300, 100, 100);
} completion:^(BOOL finished) { }];

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];
//动画类型
transition.type = kCATransitionPush;
//动画方向
transition.subtype = kCATransitionFromTop;
[testView.layer addAnimation:transition forKey:nil];

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";
//创建一个圆形的 CGPath 作为我们的关键帧动画的 path。
orbit.path = CFAutorelease(CGPathCreateWithEllipseInRect(boundingRect, NULL));
orbit.duration = 2;
orbit.additive = YES;
orbit.repeatCount = HUGE_VALF;
//恒定速度
orbit.calculationMode = kCAAnimationPaced;
//确保沿着路径旋转
orbit.rotationMode = kCAAnimationRotateAuto;
[testView.layer addAnimation:orbit forKey:@"orbit"];

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;
//摩擦力
anim.dynamicsFriction = 0.5;
//张力
anim.dynamicsTension = 250;
//质量
anim.dynamicsMass = 0.7;
[testView.layer pop_addAnimation:anim forKey:@"Animation"];

POPDecayAnimation 减速动画

1
2
3
4
5
6
7
8
9
10
11
POPDecayAnimation *anim = [POPDecayAnimation animationWithPropertyNamed:kPOPLayerPositionX];
//初始速度
anim.velocity = @(200);
//只有fromValue 没有toValue
anim.fromValue = @(100.0);
//负加速度
anim.deceleration = .998;
[anim setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
NSLog(@"执行完毕");
}];
[testView.layer pop_addAnimation:anim forKey:@"Animation"];

UIViewController动画

有时间详细整理下:

http://onevcat.com/2013/10/vc-transition-in-ios7/

http://objccn.io/issue-12-3/

参考文章:

http://objccn.io/issue-12-1/

另外.....

我的愿望是.......

世界和平.........

iOS 动画整理的更多相关文章

  1. iOS资源整理

    开发类库 http://www.code4app.com/thread-7831-1-1.html Github-iOS备忘 http://github.ibireme.com/github/list ...

  2. 解析 iOS 动画原理与实现

    这篇文章不会教大家如何实现一个具体的动画效果,我会从动画的本质出发,来说说 iOS 动画的原理与实现方式. 什么是动画 动画,顾名思义,就是能“动”的画.人的眼睛对图像有短暂的记忆效应,所以当眼睛看到 ...

  3. iOS动画学习

    学习一下动画,感谢以下大神的文章:    UIView:基础动画.关键帧动画.转场动画 Core Animation :基础动画,关键帧动画,动画组,转场动画,逐帧动画 CALayer :CALaye ...

  4. (转)iOS动画Core Animation

    文章转载:http://blog.sina.com.cn/s/blog_7b9d64af0101b8nh.html 在iOS中动画实现技术主要是:Core Animation. Core Animat ...

  5. IOS动画隐式,显式,翻页

    //  ViewController.m //  IOS动画0817 // //  Created by 张艳锋 on 15/8/17. //  Copyright (c) 2015年 张艳锋. Al ...

  6. iOS动画原理

    1. iOS动画原理 本质:动画对象(这里是UIView)的状态,基于时间变化的反应 分类:可以分为显式动画(关键帧动画和逐帧动画)和隐式动画 关键帧和逐帧总结:关键帧动画的实现方式,只需要修改某个属 ...

  7. iOS 动画基础

    原文:http://www.cnblogs.com/lujianwenance/p/5733846.html   今天说一下有关动画的基础,希望能帮助到一些刚接触iOS动画或者刚开始学习iOS的同学, ...

  8. ios 动画效果CATransition笔记

    初学ios开发,很多概念还不清楚,所以只有边学边做例子.又怕学了后面忘了前面,因此用自己的博客来纪录自己的学习历程,也是对自己学习不要懈怠做个监督. 刚学ios做动画效果.因为ios封装得很好,实现i ...

  9. IOS动画总结

    IOS动画总结   一.基本方式:使用UIView类的UIViewAnimation扩展 + (void)beginAnimations:(NSString *)animationID context ...

随机推荐

  1. Bellman_ford标准算法

    Bellman_ford求最短路可以说这个算法在某些地方和dijkstra还是有些相似的,它们的松弛操作基本还是一样的只不过dijkstra以图中每个点为松弛点对其相连接的所有边进行松弛操作 而Bel ...

  2. c#执行插入sql 时,报错:异常信息:超时时间已到。在操作完成之前超时时间已过或服务器未响应

    问题:c#执行插入sql 时,报错:异常信息:超时时间已到.在操作完成之前超时时间已过或服务器未响应 解决: SqlCommand cmd = new SqlCommand(); cmd.Comman ...

  3. kvm-1

    yum install libvirt* virt-* qemu-kvm* -y systemctl start libvirtd.service systemctl status libvirtd. ...

  4. BZOJ 4276 [ONTAK2015]Bajtman i Okrągły Robin 费用流+线段树优化建图

    Description 有n个强盗,其中第i个强盗会在[a[i],a[i]+1],[a[i]+1,a[i]+2],...,[b[i]-1,b[i]]这么多段长度为1时间中选出一个时间进行抢劫,并计划抢 ...

  5. SQL SERVER 查询语句学习:CHARINDEX

    场景介绍 项目A需要一个批量删除的功能,之前我一直用SqlTransaction去处理,今天同事告诉我可以用CHARINDEX函数去解决问题,因此我今天就研究了一下. SQL语句 ---定义要删除的数 ...

  6. EasyUI 显示表单数据 小记

    界面图:

  7. 浅谈C#中show和showDialog的区别

    [转载] A.WinForm中窗体显示  显示窗体可以有以下2种方法:  Form.ShowDialog方法 (窗体显示为模式窗体)  Form.Show方法 (窗体显示为无模式窗体) 2者具体区别如 ...

  8. Hadoop伪分布式安装步骤(hadoop0.20.2版本)

    最近在学习hadoop,自己下了个视频教程,他的教学版本是hadoop0.20.2版本,现在的最新版本都到了3.0了,版本虽然有点老,但是还是学了一下,觉得有借鉴的价值. 不废话了,开始介绍: 先说一 ...

  9. VS2015中常用快捷键的修改推荐

    首先,在VS2015中修改快捷键的步骤如下: 工具--选项--环境--键盘. 如图: 然后就是修改快捷键:(以下是个人的使用习惯,仅供参考) 1.编辑.设置选定内容的格式.设置为ctrl+E,Ctrl ...

  10. 【bzoj2783】[JLOI2012]树 树上倍增

    题目描述 在这个问题中,给定一个值S和一棵树.在树的每个节点有一个正整数,问有多少条路径的节点总和达到S.路径中节点的深度必须是升序的.节点1是根节点,根的深度是0,它的儿子节点的深度为1.路径不必一 ...