本文介绍了CATextLayer旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该真的有效,但不是:

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];

实际上,当我在transform.rotation上打印值时,它会显示正确的答案。它只是没有绘制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"]);

我做错了什么?

推荐答案

请尝试以下代码:

textLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(M_PI_2));

而不是:

[textLayer setValue:[NSNumber numberWithDouble:M_PI / 2.f forKey:@"transform.rotation"];

这篇关于CATextLayer旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 18:31