博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
core Animation之CAAnimationGroup(动画群组)
阅读量:6877 次
发布时间:2019-06-26

本文共 1507 字,大约阅读时间需要 5 分钟。

可以保存一组动画对象,将CAAnimationGroup对象加入层后,组中所有动画对象可以同时并发运行

属性解析:

animations:用来保存一组动画对象的NSArray

默认情况下,一组动画对象是同时运行的,也可以通过设置动画对象的beginTime属性来更改动画的开始时间

#import "ViewController.h" @interface ViewController ()@property(nonatomic,strong)UIButton *btn; @end @implementation ViewController - (void)viewDidLoad {    [super viewDidLoad];    self.btn=[UIButton buttonWithType:UIButtonTypeCustom];    self.btn.frame=CGRectMake(50, 100, 80, 60);    [self.btn setTitle:@"按钮" forState:UIControlStateNormal];    [self.btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];    [self.btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:self.btn];}-(void)btnClick:(id)sender{    CABasicAnimation *a1 = [CABasicAnimation animation];    a1.keyPath = @"transform.translation.y";    a1.toValue = @(100);    // 缩放动画    CABasicAnimation *a2 = [CABasicAnimation animation];    a2.keyPath = @"transform.scale";    a2.toValue = @(2.0);    // 旋转动画    CABasicAnimation *a3 = [CABasicAnimation animation];    a3.keyPath = @"transform.rotation";    a3.toValue = @(-3.1415926/4);         // 组动画    CAAnimationGroup *groupAnima = [CAAnimationGroup animation];    groupAnima.animations = @[a1, a2, a3];         //设置组动画的时间    groupAnima.duration = 2;    groupAnima.fillMode = kCAFillModeForwards;    groupAnima.removedOnCompletion = NO;    [self.btn.layer addAnimation:groupAnima forKey:nil];} - (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];}@end

转载地址:http://pfwbl.baihongyu.com/

你可能感兴趣的文章
讯飞语音错误码大全
查看>>
编译器错误消息: CS0433: The type 'global_asax' exists in both 'App_global.asax
查看>>
原生ajax显示php后台内容
查看>>
Android 富文本装饰器Spannable
查看>>
sync.Map源码分析
查看>>
error: invalid storage class for function
查看>>
seci-log 1.08 发布 增加snmp trap v2c和v3的收集
查看>>
AWK 文件处理计数
查看>>
通过libvirt使用ceph块设备
查看>>
优秀交互设计师成长指南
查看>>
SDN网络系统之MiniNet的安装与使用
查看>>
WPF中Image控件的Source属性的设置
查看>>
体绘制(Volume Rendering)概述之4:光线投射算法(Ray Casting)实现流程和代码(基于CPU的实现)...
查看>>
Python实践之(七)逻辑回归(Logistic Regression)
查看>>
PAT (Advanced Level) 1107. Social Clusters (30)
查看>>
POJ 3494 Largest Submatrix of All 1’s
查看>>
Ubuntu系统分配存储空间的建议以及给Ubuntu系统根目录扩容方法(从20GB追加100GB)...
查看>>
centos 查询mysql配置文件位置
查看>>
Eclipse IDE 使用技巧(一)
查看>>
day14 内置函数二
查看>>