这应该真的有效,但不是:
CATextLayer* textLayer = [CATextLayer layer];
textLayer.string = @"text";
[textLayer setValue:[NSNumber numberWithDouble:M_PI / 2.f forKey:@"transform.rotation"];
[self addSublayer:textLayer];
事实上,当我在transform.rotation 打印值时,它显示了正确的答案。它只是不绘制旋转的 textLayer!
NSLog(@"rotation %@", [textLayer valueForKey:@"transform.rotation"]);
我究竟做错了什么?
最佳答案
试试下面的代码:
textLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(M_PI_2));
代替:
[textLayer setValue:[NSNumber numberWithDouble:M_PI / 2.f forKey:@"transform.rotation"];
关于ios - CATextLayer 旋转?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9269462/