问题
i'm creating an iphone app.in that application i want to angle the label according to the attached screen shot.

The red color image is in the background and i want to angle the uilabel top of it
I have used the transform
method to rotate . But it does not properly angle it. label shrinks
testLabel.transform = CGAffineTransformMakeRotation(30 * M_PI / 180.0);
回答1:
Your label shrinks due to setting wrong frame. You should place your label into the UIView
and rotate this view instead of label. And also check your UIView
have no any autoresizing anchors enabled.
回答2:
Try something like this :
label.transform = CGAffineTransformMakeRotation(M_PI / 4); // 45 degree rotation
回答3:
Try this..
#define DEGREES_TO_RADIANS(angle) (angle / 180.0 * M_PI)
CGAffineTransform transform =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(0.-7));
lbl.transform = transform;
lbl.text=name;
回答4:
Use transform
property of UILabel
such like
lblComingSoon.transform = CGAffineTransformMakeRotation(M_PI_2*2.5);// your can set angle as you need.
Alos read this official documantaion.
And
For more information this Question is related to yours Question => Objective C: How can you rotate text for UIButton and UILabel?
回答5:
use this code:
label.transform = CGAffineTransformMakeRotation(2*M_PI / 3);
来源:https://stackoverflow.com/questions/17522666/how-to-angle-a-uilabel-in-ios