将CALayer旋转90度? [英] Rotating a CALayer 90 degrees?
本文介绍了将CALayer旋转90度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将 CALayer 旋转90度?我需要旋转所有包括子图层和坐标系的东西。
How do I rotate a CALayer 90 degrees? I need to rotate everything include sublayers and the coordinate system.
推荐答案
如果要设置动画效果,则在我的动画中使用类似的东西应用程序:
If I'm animating it I use something like this in my apps:
- (NSObject *) defineZRotation {
// Define rotation on z axis
float degreesVariance = 90;
// object will always take shortest path, so that
// a rotation of less than 180 deg will move clockwise, and more than will move counterclockwise
float radiansToRotate = DegreesToRadians( degreesVariance );
CATransform3D zRotation;
zRotation = CATransform3DMakeRotation(radiansToRotate, 0, 0, 1.0);
// create an animation to hold "zRotation" transform
CABasicAnimation *animateZRotation;
animateZRotation = [CABasicAnimation animationWithKeyPath:@"transform"];
// Assign "zRotation" to animation
animateZRotation.toValue = [NSValue valueWithCATransform3D:zRotation];
// Duration, repeat count, etc
animateZRotation.duration = 1.5;//change this depending on your animation needs
// Here set cumulative, repeatCount, kCAFillMode, and others found in
// the CABasicAnimation Class Reference.
return animateZRotation;
}
当然,您可以在任何地方使用它,不必从一种不适合您需要的方法。
Of course you can use it anywhere, don;t have to return it from a method if that doesn;t suit your needs.
这篇关于将CALayer旋转90度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文