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的使用以及各个参数的含义的更多相关文章

  1. MySQL 各种超时参数的含义

    MySQL 各种超时参数的含义 今日在查看锁超时的设置时,看到show variables like '%timeout%';语句输出结果中的十几种超时参数时突然想整理一下,不知道大家有没有想过,这么 ...

  2. 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 ...

  3. [转载]linux下编译php中configure参数具体含义

    编译N次了   原来这么回事 原文地址:linux下编译php中configure参数具体含义作者:捷心特 php编译参数的含义 ./configure –prefix=/usr/local/php ...

  4. 彻底搞明白find命令的-mtime参数的含义【转载】

    转自: 彻底搞明白find命令的-mtime参数的含义-goolen-ITPUB博客http://blog.itpub.net/23249684/viewspace-1156932/ 以前一直没有弄明 ...

  5. Oracle创建表时Storage参数具体含义

    本文通过图表和实例的阐述在Oracle数据库创建新表时Storage的参数具体含义. 可用于:表空间.回滚段.表.索引.分区.快照.快照日志 参数名称 缺省值 最小值 最大值 说明 INITIAL 5 ...

  6. 对tomcat7模拟并发请求及相关配置参数的含义

    这里的并不是真正的并发请求,因为for循环是间隔10毫秒,并且线程初始化也需要时间的,到真正执行http请求的时刻是不确定的.  tomcat 的运行状态可以在webapps下的manage项目查看, ...

  7. ajax 方法的使用以及方法中各参数的含义

    由于近来经常在项目中使用 ajax 这个函数,在工作之余自己查找了相关的资料,并总结了 ajax 方法的使用,以及方法中各个参数的含义,供大家学习参考使用 type: 要求为String类型的参数,请 ...

  8. opencv ORB各参数的含义

    ORB中有很多参数可以设置,在OpenCV中它可以通过ORB来创建一个ORB检测器. ORB::ORB(int nfeatures=500, float scaleFactor=1.2f, int n ...

  9. shell编程之脚本参数$@,$*,$#,$$,$?的含义

    #首先按顺序解释各个参数的含义 1.$0  表示脚本的文件名, 具体的路径信息和执行命令时的相对位置有关,例如 sakura@mi-OptiPlex-7050:~/sh$ sh args.sh arg ...

随机推荐

  1. module parameters

    Parameter values can be assigned at load time by insmod or modprobe(this can read parameter from con ...

  2. PAT 乙级 1004. 成绩排名

    读入n名学生的姓名.学号.成绩,分别输出成绩最高和成绩最低学生的姓名和学号. 输入格式:每个测试输入包含1个测试用例,格式为 第1行:正整数n 第2行:第1个学生的姓名 学号 成绩 第3行:第2个学生 ...

  3. boostrap插件

    第一章:模态弹出框 一.导入JavaScript插件 Bootstrap的JavaScript插件可以单独导入到页面中,也可以一次性导入到页面中.因为在Bootstrap中的JavaScript插件都 ...

  4. Java 泛型 泛型代码和虚拟机

    Java 泛型 泛型代码和虚拟机 @author ixenos 类型擦除.原始类型.给JVM的指令.桥方法.Java泛型转换的事实 l  类型擦除(type erasure) n  Java泛型的处理 ...

  5. 2016弱校联盟十一专场10.2——Around the World

    题目链接:Around the World 题意: 给你n个点,有n-1条边,现在这n-1条边又多增加了ci*2-1条边,问你有多少条欧拉回路 题解: 套用best定理 Best Theorem:有向 ...

  6. hdu_5889_Barricade(最小割+最短路)

    题目链接:hdu_5889_Barricade 题意: 有n个点,m条边,每个边的长度都为1,每个边有一个消耗w,如果要阻断这条路,那么就会消耗w,现在让你阻断点1到点n的所有最短路,问你最小的消耗是 ...

  7. AnimatorController动画融合树

    通过Unity动画状态机,能帮我们轻松处理转换各个动画片断,达到想要的效果,但是如果仅仅是一个个动画的硬生生的切换,那么看起来就非常突然,而不真实了,在质量要求比较高的游戏中,特别是动作游戏,我们就不 ...

  8. 重新认识C++

    By Jensen,2014.5.28 晚   一直觉得C++也没有什么高级的,但是看了知乎上有人问"怎么样才算精通C++"之后,我很惭愧,原来我的认识这么肤浅.所以我下定决心再学 ...

  9. 如何安装VM Tool软件包

    在linux下,我们想把原windows操作系统下的一些文件拷入到新linux系统中,在windows下对文件(夹)进行复制,在linux下无法进行粘贴,何故?这是因为新装的linux操作系统未安装V ...

  10. PHP中使用CURL(五)

    curl伪造IP和来源 client.php请求server.php client.php <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_U ...