如何在ios中调整uilabel角度

时间:2013-07-08 09:02:57

标签: iphone ios uilabel

我正在创建一个iphone app.in该应用程序我想根据附加的屏幕截图调整标签角度。 enter image description here(参见$ 120标签)

红色图像在背景中,我想将uilabel的顶部角度调整

我使用transform方法进行旋转。但它并没有恰当的角度。标签缩小

testLabel.transform = CGAffineTransformMakeRotation(30 * M_PI / 180.0);

5 个答案:

答案 0 :(得分:5)

尝试这样的事情:

label.transform = CGAffineTransformMakeRotation(M_PI / 4); //  45 degree rotation 

答案 1 :(得分:5)

试试这个..

#define DEGREES_TO_RADIANS(angle) (angle / 180.0 * M_PI)


CGAffineTransform transform = 
    CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(0.-7));
    lbl.transform = transform;
    lbl.text=name;

答案 2 :(得分:3)

由于设置了错误的框架,您的标签会缩小。您应该将标签放入UIView并旋转此视图而不是标签。并检查您的UIView是否启用了任何自动调整锚点。

答案 3 :(得分:2)

使用transform

UILabel属性

lblComingSoon.transform = CGAffineTransformMakeRotation(M_PI_2*2.5);// your can set angle as you need.

Alos read this official documantaion.
并且

有关详情,此问题与您的问题相关问题=> Objective C: How can you rotate text for UIButton and UILabel?

答案 4 :(得分:0)

使用此代码:

label.transform = CGAffineTransformMakeRotation(2*M_PI / 3);