FROM : william van braam
DATE : Tue May 13 18:53:33 2008
Rotating a text layer to any angle with CATransform3DMakeRotation in a
transaction goes fine, unless you stop rotating at 135 or 315 degrees
clockwise from the vertical normal. In those two cases
bounds.size.width and bounds.size.height appear to exchange values, so
that the string gets clipped.
This has got me puzzled for days now, and wondering if it's a bug in CA.
Any comments greatly appreciated.
The setup is very simple.
A CALayer *rL, including:
rL.layoutManager = [CAConstraintLayoutManager layoutManager];
Add a sublayer to rL: CATextLayer *tL, with a:
tL.string = (NSString *)@"This is a long string";
Color the border of tL, so as to see what happens to tL when rotating.
Fix tL in the center of rL for an axis of rotation:
[tL addConstraint:[CAConstraint
constraintWithAttribute:kCAConstraintMidX
relativeTo:@"superlayer" attribute:kCAConstraintMidX ]];
[tL addConstraint:[CAConstraint
constraintWithAttribute:kCAConstraintMidY
relativeTo:@"superlayer" attribute:kCAConstraintMidY ]];
Rotate tL:
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:3.0f]
forKey:kCATransactionAnimationDuration];
tL.transform = CATransform3DMakeRotation(phi, 0.0, 0.0, 1.0);
[CATransaction commit];
That goes well, except when stopping the rotation at
phi = M_PI_2 + M_PI_4 (135 degrees), or phi = M_PI + M_PI_2 + M_PI_4
(315 degrees, which is opposite 135 degrees).
Thanks.
Regards,
William
DATE : Tue May 13 18:53:33 2008
Rotating a text layer to any angle with CATransform3DMakeRotation in a
transaction goes fine, unless you stop rotating at 135 or 315 degrees
clockwise from the vertical normal. In those two cases
bounds.size.width and bounds.size.height appear to exchange values, so
that the string gets clipped.
This has got me puzzled for days now, and wondering if it's a bug in CA.
Any comments greatly appreciated.
The setup is very simple.
A CALayer *rL, including:
rL.layoutManager = [CAConstraintLayoutManager layoutManager];
Add a sublayer to rL: CATextLayer *tL, with a:
tL.string = (NSString *)@"This is a long string";
Color the border of tL, so as to see what happens to tL when rotating.
Fix tL in the center of rL for an axis of rotation:
[tL addConstraint:[CAConstraint
constraintWithAttribute:kCAConstraintMidX
relativeTo:@"superlayer" attribute:kCAConstraintMidX ]];
[tL addConstraint:[CAConstraint
constraintWithAttribute:kCAConstraintMidY
relativeTo:@"superlayer" attribute:kCAConstraintMidY ]];
Rotate tL:
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:3.0f]
forKey:kCATransactionAnimationDuration];
tL.transform = CATransform3DMakeRotation(phi, 0.0, 0.0, 1.0);
[CATransaction commit];
That goes well, except when stopping the rotation at
phi = M_PI_2 + M_PI_4 (135 degrees), or phi = M_PI + M_PI_2 + M_PI_4
(315 degrees, which is opposite 135 degrees).
Thanks.
Regards,
William
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

