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?
Try the following code:
textLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(M_PI_2));
instead of:
[textLayer setValue:[NSNumber numberWithDouble:M_PI / 2.f forKey:@"transform.rotation"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With