Question
This should really work, but is not:
CATextLayer* textLayer = [CATextLayer layer];
textLayer.string = @"text";
[textLayer setValue:[NSNumber numberWithDouble:M_PI / 2.f forKey:@"transform.rotation"];
[self addSublayer:textLayer];
in fact, when i print the value at transform.rotation, it shows the correct answer. it just doesn't draw the textLayer rotated!
NSLog(@"rotation %@", [textLayer valueForKey:@"transform.rotation"]);
What am I doing wrong?
Solution
Try the following code:
textLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(M_PI_2));
instead of:
[textLayer setValue:[NSNumber numberWithDouble:M_PI / 2.f forKey:@"transform.rotation"];
OTHER TIPS
The CALayer will remember any value you give it. I believe what you have it wrong because you need to rotate with "transform.rotation.z".
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow