开发者

Display text at an angle

I am writing an app for the iPad/iPhone and am looking for a suggestion on how I would go about displaying开发者_Python百科 text at an arbitrary angle on the iPhone and iPad using xCode?

Thanks for the advice.

Best, Tony


You can set the transform property of any UIView—such as, in this case, a UILabel—to adjust its rotation, among many other things. For example:

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

would rotate your label by 30 degrees.


Not exactly sure if this is what you're looking for but just add the text to a UILabel:

UILabel *label = [[UILabel alloc] initWithFrame:someFrame];
label.text = @"Some Text"; 

and then add a transform to the label to rotate it to whichever arbitrary angle you desire:

label.transform = CGAffineTransformMakeRotation(someAngleInRadians);
[self.view addSubview:label]; 
[label release]; 

Just set the value for someAngleInRadians to the angle you wish to rotate the text to (in radians of course).

Cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜