//1.创建动画
CABasicAnimation *anima=[CABasicAnimation animationWithKeyPath:@"bounds"];
//1.1设置动画执行时间
anima.duration=2.0;
//1.2设置动画执行完毕后不删除动画
anima.removedOnCompletion=YES;
//1.3设置保存动画的最新状态
//kCAFillModeForwards保存动画的最新状态 kCAFillModeBackwards保存最开始状态
anima.fillMode=kCAFillModeForwards;
//1.4修改属性,执行动画
anima.toValue=[NSValue valueWithCGRect:CGRectMake(0, 0, 200, 200)];
//2.添加动画到layer
[redView.layer addAnimation:anima forKey:nil];

 //1.创建动画
CABasicAnimation *anima=[CABasicAnimation animationWithKeyPath:@"transform"];
//1.1设置动画执行时间
anima.duration=2.0;
//1.2修改属性,执行动画
anima.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI_2+M_PI_4, 1, 1, 0)];
//1.3设置动画执行完毕后不删除动画
anima.removedOnCompletion=NO;
//1.4设置保存动画的最新状态
anima.fillMode=kCAFillModeBackwards;
anima.repeatCount = 1000; //2.添加动画到layer
[redView.layer addAnimation:anima forKey:nil];

CABasicAnimation *anima=[CABasicAnimation animation];
//1.1告诉系统要执行什么样的动画
anima.keyPath=@"position";
//设置通过动画,将layer从哪儿移动到哪儿
anima.fromValue=[NSValue valueWithCGPoint:CGPointMake(0, 0)];
anima.toValue=[NSValue valueWithCGPoint:CGPointMake(300, 300)];
anima.duration = 1.0f;
//1.2设置动画执行完毕之后不删除动画
anima.removedOnCompletion=YES;
//1.3设置保存动画的最新状态
anima.fillMode=kCAFillModeForwards;
//设置代理
anima.delegate=self;
//2.添加核心动画到layer
[redView.layer addAnimation:anima forKey:nil];

CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
rotationAnimation.duration = 1;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = MAXFLOAT;
[redView.layer addAnimation:rotationAnimation forKey:nil ];
 //透明动画
CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
opacityAnim.removedOnCompletion = YES;
 //缩放动画
CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5, 0.5, 0.1)];

最新文章

  1. .a静态库构架合成
  2. C++ Windows 下 根据进程名获取进程ID 以及该进程下所有窗口的句柄
  3. Linq Group By
  4. C# C/S WPF 远程操作服务器上面的文件
  5. ASP.NET导出bdf文件
  6. WPFの exit()和close()两个方法的用法
  7. 联合与枚举 、 高级指针 、 C语言标准库(一)
  8. android 51 有序广播
  9. 转载----给JavaScript初学者的24条最佳实践
  10. 【Spring】基于注解的实现SpringMVC+MySQL
  11. Http学习之使用HttpURLConnection发送post和get请求(3)
  12. (转)FastJson---高性能JSON开发包
  13. 流式数据分析模型kafka+storm
  14. 怎么写自己的CMakeLists.txt
  15. Docker 安装rabbitMQ
  16. Kong(V1.0.2) Clustering Reference
  17. H5 video标签的第二种格式
  18. python内置函数zip
  19. Lintcode9-Fizz Buzz-Easy
  20. 2018.10.31 NOIP训练 锻造(方程式期望入门题)(期望dp)

热门文章

  1. [Bayes] Understanding Bayes: A Look at the Likelihood
  2. cocos2d-x游戏引擎核心(3.x)----事件分发机制之事件从(android,ios,desktop)系统传到cocos2dx的过程浅析
  3. 浅谈JavaScript对象数组根据某属性sort升降序排序
  4. 【Scikit】实现Multi-label text classification代码模板
  5. AWS EC2 使用root账户密码登陆
  6. 导航+左侧菜单+tab切换模板
  7. iis和tomcat(整合)
  8. Mapper 赋值对应实体属性
  9. element UI 导航栏根据路径来确定默认选中
  10. mapReducer 去重副的单词