CABasicAnimation x y z 轴旋转动画

x轴旋转:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
theAnimation.duration=1;
theAnimation.fromValue = [NSNumber numberWithFloat:0];
theAnimation.toValue = [NSNumber numberWithFloat:3.1415926];
 [yourView.layer addAnimation:theAnimation forKey:@"animateTransformx"];

y轴旋转:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
theAnimation.duration=1;
theAnimation.fromValue = [NSNumber numberWithFloat:0];
theAnimation.toValue = [NSNumber numberWithFloat:3.1415926];
 [yourView.layer addAnimation:theAnimation forKey:@"animateTransformy"];

z轴旋转:
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
theAnimation.duration=1;
theAnimation.fromValue = [NSNumber numberWithFloat:0];
theAnimation.toValue = [NSNumber numberWithFloat:3.1415926];
 [yourView.layer addAnimation:theAnimation forKey:@"animateTransformz"];

以上缩放是以view的中心点为中心缩放的,如果需要自定义缩放点,可以设置卯点:
//中心点
[yourView.layer setAnchorPoint:CGPointMake(0.5, 0.5)];

//左上角
[yourView.layer setAnchorPoint:CGPointMake(0, 0)];

//右下角
[yourView.layer setAnchorPoint:CGPointMake(1, 1)];

可设参数:
theAnimation.repeatCount = 5;
theAnimation.autoreverses = YES;
theAnimation.removedOnCompletion = YES;

时间: 2024-08-11 03:37:40

CABasicAnimation x y z 轴旋转动画的相关文章

直线绕z轴旋转所成曲面的方程

直线:(x-x0)/L=(y-y0)/M=(z-z0)/N绕z轴旋转所成曲面的方程为: x2+y2=α+β(z-z0)+γ(z-z0)2 其中 α=x02+y02 β=(2/N)(Lx0+My0) γ=(L2+M2)/N2 绕其他两个轴的方程类似于此. 原文地址:https://www.cnblogs.com/jmz11111/p/8157604.html

绕X 轴 Y轴 Z轴旋转的结果

void warp_perspect_3_angle(cv::Mat face, float roll, float yaw, float pitch) { cv::Mat face_img = face.clone(); int imgHeight = face_img.rows; int imgWidth = face_img.cols; float alpha, beta, gamma; alpha = pitch * 3.1415926 / 180; beta = yaw* 3.1415

iOS 旋转动画添加3D效果

本文 出处 参考   http://blog.sina.com.cn/s/blog_71715bf801019ut9.html  自己mark下 例子代码可以在 http://download.csdn.net/detail/p709723778/5034622 下载 本文重点在改变CALayer默认使用的正交投影,去使用透视投影矩阵.iOS的UI是基于UIView类的,我们能看到的每个UI元素都是UIView或者UIView的子类.View按树形结构组织起来,树根是UIWindow. View

Android自定义动画类——实现3D旋转动画

Android中的补间动画分为下面几种: (1)AlphaAnimation :透明度改变的动画. (2)ScaleAnimation:大小缩放的动画. (3)TranslateAnimation:位移变化的动画. (4)RotateAnimation:旋转动画. 然而在实际项目中透明度.缩放.位移.旋转这几种动画并不能满足我们的需求,比如我们需要一个类似下面的3D旋转动画. 这时候就需要用到自定义动画,自定义动画需要继承Animation,并重写applyTransformation(floa

矩阵变换:沿任意轴旋转及其推导

http://blog.csdn.net/zsq306650083/article/details/8773996 1. 2D中绕原点旋转 设基向量p,q和r分别是朝向+x,+y和+z方向的单位向量. 旋转角度为θ,基向量p,q绕原点旋转,得到新的基向量p`和q` 即旋转矩阵R(θ)为 2. 3d中绕坐标轴旋转 01. 绕x轴旋转,基向量q和r旋转θ,得到新的基向量q`和r` 即旋转矩阵Rx(θ)为: 02. 绕y轴旋转,基向量p和r旋转θ,得到新的基向量p`和r` 即旋转矩阵Ry(θ)为: 0

使用Shader制作loading旋转动画

效果图: 1.绕Z轴旋转的旋转矩阵 2.UV旋转的步骤 (1) 由于旋转矩阵是绕原点旋转的,要把要旋转的UV坐标平移到原点 1 i.uv -= float2(0.5, 0.5); 2 float2 tempUV = i.uv; (2)旋转UV坐标 1 i.uv.x = cos(_Speed * _Time.y) * tempUV.x - sin(_Speed * _Time.y)*tempUV.y; 2 i.uv.y = sin(_Speed * _Time.y) * tempUV.x + co

matplotlib画3D图修改X,Y,Z,colorbar的刻度值

修改X,Y,Z轴的刻度值 from matplotlib.ticker import MultipleLocator,FuncFormatter from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib import cm from matplotlib import colors from matplotlib.ticker import LinearLocator, Form

Android立体旋转动画实现与封装(支持以X、Y、Z三个轴为轴心旋转)

本文主要介绍Android立体旋转动画,或者3D旋转,下图是我自己实现的一个界面 立体旋转分为以下三种: 1. 以X轴为轴心旋转 2. 以Y轴为轴心旋转 3. 以Z轴为轴心旋转--这种等价于android默认自带的旋转动画RotateAnimation 实现立体旋转核心步骤: 1. 继承系统Animation重写applyTransformation方法 通过applyTransformation方法的回调参数 float interpolatedTime, Transformation t 来

(转)android3D动画,绕y轴旋转

原文地址:http://blog.csdn.net/x_i_a_o_h_a_i/article/details/40449847 其实网上的3D旋转的例子很多,在这里我只是想把其代码做一个解释. 先上图: 代码: TurnAroundActivity /** * 图片浏览器的主Activity. * * @author guolin */ public class TurnAroundActivity extends Activity { /** * 根布局 */ private Relativ