Core Animation之CATransform3D学习篇
来源:互联网 发布:c语言问号表达式 编辑:程序博客网 时间:2024/06/02 02:03
3D,顾名思义就是可以在z轴上动作,这里列举三个用例
//用例1 scale
CABasicAnimation *theAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
CATransform3D transform = CATransform3DMakeScale(0.5, 0.5, 1.0); //x,y,z放大缩小倍数
NSValue *value = [NSValue valueWithCATransform3D:transform];
[theAnimation setToValue:value];
transform = CATransform3DMakeScale(1.0, 1.0, 1.0);
value = [NSValue valueWithCATransform3D:transform];
[theAnimation setFromValue:value];
[theAnimation setAutoreverses:YES]; //原路返回的动画一遍
[theAnimation setDuration:1.0];
[theAnimation setRepeatCount:2];
[layer addAnimation:theAnimation forKey:nil];
//用例2 rotate
......
CATransform3D transform = CATransform3DMakeRotation(1.57, 1, 1, 0); //1.57表示所转角度的弧度 = 90Pi/180 = 90*3.14/180
NSValue *value = [NSValue valueWithCATransform3D:transform];
[theAnimation setToValue:value];
transform = CATransform3DMakeRotation(0, 1, 1, 0);
value = [NSValue valueWithCATransform3D:transform];
[theAnimation setFromValue:value];
......
//用例3 scale+rotate+position
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"];
CATransform3D rotateTransform = CATransform3DMakeRotation(1.57, 0, 0, -1);
CATransform3D scaleTransform = CATransform3DMakeScale(5, 5, 5);
CATransform3D positionTransform = CATransform3DMakeTranslation(0, 0, 0);//位置移动
CATransform3D combinedTransform = CATransform3DConcat(rotateTransform, scaleTransform); //Concat就是combine的意思
combinedTransform = CATransform3DConcat(combinedTransform, positionTransform);//再combine一次把三个动作连起来
[anim setFromValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]]; //放在3D坐标系中最正的位置
[anim setToValue:[NSValue valueWithCATransform3D:combinedTransform]];
[anim setDuration:5.0f];
[layer addAnimation:anim forKey:nil];
[layer setTransform:combinedTransform]; //如果没有这句,layer执行完动画又会返回最初的state
- Core Animation之CATransform3D学习篇
- Core Animation之CATransform3D学习篇
- Core Animation之CATransform3D学习篇
- Core Animation之CATransform3D学习篇
- 10. Core Animation之CATransform3D学习篇
- Core Animation之CATransform3D学习篇
- Core Animation之CATransform3D:矩阵变换3D旋转
- Core Animation研究系列 : CATransform3D
- Core Animation研究系列 : CATransform3D 矩阵变换之立方体旋转实现细节
- Core Animation学习之anchorPoint
- Core Animation学习之anchorPoint
- iOS学习之 - Core Animation
- core animation学习
- Core Animation学习笔记
- Core Animation学习----CAkeyframeAnimation
- Core Animation学习笔记
- Core Animation学习笔记
- Core Animation学习笔记
- PHP操作SQL Server 2008/2012
- [leetcode 93] Restore IP Addresses
- 【HDU 3949】XOR
- 设计模式-模版方法模式
- android共享数据之SharedPreferences-组建间的数据共享和应用间的数据共享
- Core Animation之CATransform3D学习篇
- 操作系统IO模型
- 正则表达式 - 匹配规则
- Exception in thread "main" java.sql.SQLException: Connections could not be acquired from the underly
- 一句话脚本系列之获取eth0网卡的IP地址(或MAC地址)
- HDU5139 Card 求期望
- opencv从两路视频中获取图片
- 基础之Git分布式版本控制系(转)
- 【项目管理】 PMBOK 基础概念 (引论 PMBOK 笔记)