码迷,mamicode.com
首页 > 其他好文 > 详细

CABasicAnimation x y z 轴旋转动画

时间:2015-05-01 12:00:02      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:

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;

CABasicAnimation x y z 轴旋转动画

标签:

原文地址:http://www.cnblogs.com/417460188dy/p/4470481.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!