我想围绕 X 轴旋转 UILabel,并为其设置动画。但是当动画开始时,标签的文本会被水平切成两半。下半部分消失,上半部分在旋转。为什么?
代码如下:
CATransform3D _3Dt = CATransform3DMakeRotation(radians(90.0f), 1.0, 0.0, 0.0);
CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
transformAnimation.removedOnCompletion = NO;
transformAnimation.toValue = [NSValue valueWithCATransform3D:_3Dt];
transformAnimation.fillMode = kCAFillModeForwards;
(SDK 3.0)
最佳答案
X 轴?这意味着在旋转期间 UILabel 的一半将有 z > 0
(在屏幕前)一半将有 z < 0
(在屏幕后面)。
如果 z == 0
处还有其他层它们将覆盖您的 UILabel 的 z < 0
一半。
尝试增加标签层的 zPosition
.
关于iPhone动画: why does rotating a UILabel around X axis cut off its bottom half?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2301067/