6

I want to rotate a UILabel around the X axis, and animating it. But when the animation starts, the text of the label is cut in two, horizontally. The bottom half disappears, the upper half is rotating. Why?

Here's the code:

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)

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
johnnyMac
  • 381
  • 2
  • 14

1 Answers1

14

X axis? That means during the rotation half of the UILabel will have z > 0 (in front of the screen) and half will have z < 0 (behind the screen).

If there's other layers at z == 0 they will cover your UILabel's z < 0 half.

Try to increase your label's layer's zPosition.

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • This is critical to 3D transforms executing correctly in multi-layer scenes. +1, especially since such a key point doesn't seem to get mentioned much. Every tutorial should point out adjusting the zPosition to avoid cross-contamination... – SG1 Feb 12 '12 at 18:28
  • I had the same problem with my rotated images (UIImageView) being cut. I don't know how many hours I was looking for a solution before I found this answer. Thanks a lot! – Mariusz Schimke Aug 12 '12 at 16:32