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

时间: 2024-08-06 20:08:16

CATransform3D的使用以及各个参数的含义的相关文章

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

编译N次了   原来这么回事 原文地址:linux下编译php中configure参数具体含义作者:捷心特 php编译参数的含义 ./configure –prefix=/usr/local/php                      php 安装目录 –with-apxs2=/usr/local/apache/bin/apxs –with-config-file-path=/usr/local/php/etc      指定php.ini位置 –with-mysql=/usr/local

远程桌面Default.rdp 中各个参数的含义

存储在 Default.rdp 文件中的设置 默认情况下,将在“我的文档”文件夹中创建 Default.rdp 文件.以下 RDP 设置存储在 Desktop.rdp 文件中: desktopwidth:i 此设置对应于您在远程桌面连接“选项”中的“显示”选项卡上选择的桌面宽度. 注意:基于 Microsoft Windows CE 的设备只支持全屏模式. desktopheight:i 此设置对应于您在远程桌面连接“选项”中的“显示”选项卡上选择的桌面高度. 注意:基于 Microsoft W

tcp/ip协议listen函数中backlog参数的含义

listen函数的定义如下所示: #include <sys/socket.h> int accept(int sockfd, struct sockaddr * restrict addr, socklen_t *restrict len); 返回值:若成功则返回文件(套接字)描述符,若出错则返回-1 int listen(int sockfd, int backlog);返回值:若成功则返回0:若出错则返回-1 之前看书的时候对listen函数的参数backlog不是很理解,今天看到一篇很

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

本文通过图表和实例的阐述在Oracle数据库创建新表时Storage的参数具体含义. 可用于:表空间.回滚段.表.索引.分区.快照.快照日志 参数名称 缺省值 最小值 最大值 说明 INITIAL 5(数据块) 2(数据块) 操作系统限定 分配给Segment的第一个Extent的大小,以字节为单位,这个参数不能在alter语句中改变,如果指定的值小于最小值,则按最小值创建. NEXT 5(数据块) 1(数据块) 操作系统限定 第二个Extent的大小等于NEXT的初值,以后的NEXT值=前一N

Service 中onStartCommand方法参数的含义

在Service中onStartCommand(Intent intent, int flags, int startId)这三个参数的含义分别是,intent就是startService(Intent intent)中的intent;flags代表flags表示启动服务的方式: Additional data about this start request. Currently either 0, START_FLAG_REDELIVERY, or START_FLAG_RETRY. STA

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 maintains two queues :要明白backlog参数的含义,我们必须明白对于一个listening socket,kernel维护者两个队列: 1.An incomplete connection queue, which contains an entry for each SYN t

关于java方法中Object... args参数的含义

关于java方法中Object... args参数的含义 在阅读google发布的volley源码时,突然看到一个方法中存在这样的写法,如 :v(String format, Object... args) 不明白什么意思,琢磨着为什么要这样写呢,跟Object[] args是一个意思吗?为什么用三个点代替呢?后来查阅了下文档,原来这是JDK1.5新增语法,新特性,动态参数或者是可变参数的意思. 举例: 有个方法v,调用v方法 v(里面写多少参数都行); 比如: v(1,"s"); v

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

由于近来经常在项目中使用 ajax 这个函数,在工作之余自己查找了相关的资料,并总结了 ajax 方法的使用,以及方法中各个参数的含义,供大家学习参考使用 type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如put和 delete也可以使用,但仅部分浏览器支持. timeout: 要求为Number类型的参数,设置请求超时时间(毫秒).此设置将覆盖$.ajaxSetup()方法的全局设 置. async:要求为Boolean类型的参数

MySQL 各种超时参数的含义

MySQL 各种超时参数的含义 今日在查看锁超时的设置时,看到show variables like '%timeout%';语句输出结果中的十几种超时参数时突然想整理一下,不知道大家有没有想过,这么多的timeout参数,到底有什么区别,都是做什么用的呢? MySQL [(none)]> show variables like '%timeout%'; +------------------------------+----------+ | Variable_name | Value | +