tags:

views:

102

answers:

3

How do you draw text on a diagonal? In other words, a horizontal UILabel that's rotated, say, 45 degrees?

+1  A: 

You can .transform the label, e.g.

theLabel.transform = CGAffineTransformMakeRotation(M_PI / 4);   // pi/4 = 45 degrees.
KennyTM
+1  A: 
// rotate 45 degrees
label.transform = CGAffineTransformMakeRotation(M_PI / 4);

You may want to do this before adding the label to its parent view.

Senseful
Thanks everyone!
Martin
+1  A: 

You can use a CGAffineTransform to rotate the view.

myLabel.transform = CGAffineTransformMakeRotation((45*M_PI) / 180);
Jasarien
Posting from an iPad is obviously too slow when writing code is needed. There were no answers when I started posting. Now there are 3 :(
Jasarien