LilMoke
LilMoke

Reputation: 3444

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 text at an arbitrary angle on the iPhone and iPad using xCode?

Thanks for the advice.

Best, Tony

Upvotes: 1

Views: 3328

Answers (2)

Noah Witherspoon
Noah Witherspoon

Reputation: 57149

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.

Upvotes: 11

Brenton Morse
Brenton Morse

Reputation: 2567

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

Upvotes: 2

Related Questions