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;
轉載于:https://www.cnblogs.com/417460188dy/p/4470481.html
總結
以上是生活随笔為你收集整理的CABasicAnimation x y z 轴旋转动画的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java 设计模式-【单例模式】
- 下一篇: MVC5网站部署到IIS7