How do I draw an NSString at an angle?

Here’s an example that uses a transform to rotate the drawing context. Essentially it’s just like setting a color or shadow, just make sure to use -concat instead of -set.

CGFloat rotateDeg = 4.0f;
NSAffineTransform *rotate = [[NSAffineTransform alloc] init];

[rotate rotateByDegrees:rotateDeg];
[rotate concat];

// Lock focus if needed and draw strings, images here.

[rotate release];

Leave a Comment