CATransform3D的使用以及各个参数的含义
1. 缩放
CABasicAnimation *theAnimation=[CABasicAnimation animationWithKeyPath:@"transform"];
//x,y,z放大缩小倍数
CATransform3D transform=CATransform3DMakeScale(0.5, 0.5, 1.0);
NSValue *value=[NSValue valueWithCATransform3D:transform];
[theAnimation setToValue:value];
transform=CATransform3DMakeScale(1.0, 1.0, 1.0);
value=[NSValue valueWithCATransform3D:transform];
[theAnimation setAutoreverses:YES]; //原路返回的动画一遍
[theAnimation setDuration:1.0];//执行动画的时间
[theAnimation setRepeatCount:2];//执行动画的次数
[layer addAnimation:theAnimation forKey:nil];
2.动画旋转
CABasicAnimation *theAnimation=[CABasicAnimation animationWithKeyPath:@"transform"];
CATransform3D transform=CATransform3DMakeRotation(90*M_PI/180, 1, 1, 0);//
NSValue *value = [NSValue valueWithCATransform3D:transform];
[theAnimation setToValue:value];
/*
angle:旋转的弧度,所以要把角度转换成弧度:角度 * M_PI / 180。
x:向X轴方向旋转。值范围-1 --- 1之间
y:向Y轴方向旋转。值范围-1 --- 1之间
z:向Z轴方向旋转。值范围-1 --- 1之间
向 X轴,Y轴都旋转60度,就是沿着对角线旋转。
*/
transform = CATransform3DMakeRotation(1, 1, 1, 0);
value = [NSValue valueWithCATransform3D:transform];
[theAnimation setFromValue:value];
theAnimation.duration=2;
theAnimation.autoreverses=YES;
[layer addAnimation:theAnimation forKey:nil];
3.组动画
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"];
CATransform3D rotateTransform = CATransform3DMakeRotation(1.57, 0, 0, -1);
CATransform3D scaleTransform = CATransform3DMakeScale(2, 2, 2);
//(CGFloat tx,CGFloat ty, CGFloat tz ,x,y,z轴的偏移量
CATransform3D positionTransform = CATransform3DMakeTranslation(1, 200, 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
CATransform3D的使用以及各个参数的含义的更多相关文章
- MySQL 各种超时参数的含义
MySQL 各种超时参数的含义 今日在查看锁超时的设置时,看到show variables like '%timeout%';语句输出结果中的十几种超时参数时突然想整理一下,不知道大家有没有想过,这么 ...
- tcp/ip协议listen函数中backlog参数的含义与php-fpm的502 Bad Gateway
To understand the backlog argument, we must realize that for a given listening socket, the kernel ma ...
- [转载]linux下编译php中configure参数具体含义
编译N次了 原来这么回事 原文地址:linux下编译php中configure参数具体含义作者:捷心特 php编译参数的含义 ./configure –prefix=/usr/local/php ...
- 彻底搞明白find命令的-mtime参数的含义【转载】
转自: 彻底搞明白find命令的-mtime参数的含义-goolen-ITPUB博客http://blog.itpub.net/23249684/viewspace-1156932/ 以前一直没有弄明 ...
- Oracle创建表时Storage参数具体含义
本文通过图表和实例的阐述在Oracle数据库创建新表时Storage的参数具体含义. 可用于:表空间.回滚段.表.索引.分区.快照.快照日志 参数名称 缺省值 最小值 最大值 说明 INITIAL 5 ...
- 对tomcat7模拟并发请求及相关配置参数的含义
这里的并不是真正的并发请求,因为for循环是间隔10毫秒,并且线程初始化也需要时间的,到真正执行http请求的时刻是不确定的. tomcat 的运行状态可以在webapps下的manage项目查看, ...
- ajax 方法的使用以及方法中各参数的含义
由于近来经常在项目中使用 ajax 这个函数,在工作之余自己查找了相关的资料,并总结了 ajax 方法的使用,以及方法中各个参数的含义,供大家学习参考使用 type: 要求为String类型的参数,请 ...
- opencv ORB各参数的含义
ORB中有很多参数可以设置,在OpenCV中它可以通过ORB来创建一个ORB检测器. ORB::ORB(int nfeatures=500, float scaleFactor=1.2f, int n ...
- shell编程之脚本参数$@,$*,$#,$$,$?的含义
#首先按顺序解释各个参数的含义 1.$0 表示脚本的文件名, 具体的路径信息和执行命令时的相对位置有关,例如 sakura@mi-OptiPlex-7050:~/sh$ sh args.sh arg ...
随机推荐
- js中三目运算符和&& || 符的个人浅见
这两天看到别人写的代码,感觉很牛逼,如下,大神请忽视 $(".lgn").on("click", function() { var a = {}; a.logi ...
- js字符串函数 [http://www.cnblogs.com/qfb620/archive/2011/07/28/2119799.html]
JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串.var a = "hello";var b = ",world";var c = a ...
- TESTNG重试、截屏、监听
http://qa.blog.163.com/blog/static/19014700220138585422735/
- magento数据查询
一.查询出所有的数据: 1.以mysql查询语句在magento里执行,以此来查询你所需要的语句! $read = Mage::getSingleton('core/resource')->ge ...
- HDU 2212 DFS
Problem Description A DFS(digital factorial sum) number is found by summing the factorial of every d ...
- HDU 1312 Red and Black (DFS)
Problem Description There is a rectangular room, covered with square tiles. Each tile is colored eit ...
- hdu_5904_LCIS(DP)
题目链接:hdu_5904_LCIS 题意: 给你两串数,让你找这两串数的最长公共子序列,并且这个最长公共子序列是连续的数值 题解: 我们首先先分别处理出a,b的每个数的最长连续的长度 然后随便找一串 ...
- LeetCode OJ 78. Subsets
Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subset must ...
- LeetCode OJ 39. Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C wher ...
- BestCoder Round #86 A B C
这次BC终于不像上次一样惨烈 终于A了三题…… 终测ing…… 发一波题解…… A.Price List A题十分无脑 只要把所有数加起来存到sum里 询问的时候大于sum输出1 否则输出0就行了…… ...