[iPhone] Rotate NSString
Hey Guys,
This seems like a pretty common question but I can't seem to find it posted anywhere (on this forum or elsewhere).
My question is: is it possible to do a rotation on a "NSString drawInRect" call.
I like using the "NSString drawInRect" call since it's able to take long strings and wrap them into a several lines. But I was hoping I could rotate this box a little.
I have looked on google for a solution for rotating text and I found this:
------------------------------------
CGContextSelectFont (context, "Helvetica", 60, kCGEncodingMacRoman);
CGContextSetCharacterSpacing (context, 10);
CGContextSetTextDrawingMode (context, kCGTextFill);
CGContextSetGrayFillColor(context, 0.0, 1.0);
CGAffineTransform myTextTransform = CGAffineTransformRotate(CGAffineTransformScale(CGAffineTransformIdentity, 1.f, -1.f ),(-1));
CGContextSetTextMatrix (context, myTextTransform);
CGContextShowTextAtPoint (context, 0, 0, "Quartz 2D", 9);
------------------------------------
The code works fine for me, but it doesn't have that line wrapping feature that I get with the "NSString drawInRect" call.
Is there anyway to get my lines of text to rotate?
Thanks for the help.
Cheers,
Mark
This seems like a pretty common question but I can't seem to find it posted anywhere (on this forum or elsewhere).
My question is: is it possible to do a rotation on a "NSString drawInRect" call.
I like using the "NSString drawInRect" call since it's able to take long strings and wrap them into a several lines. But I was hoping I could rotate this box a little.
I have looked on google for a solution for rotating text and I found this:
------------------------------------
CGContextSelectFont (context, "Helvetica", 60, kCGEncodingMacRoman);
CGContextSetCharacterSpacing (context, 10);
CGContextSetTextDrawingMode (context, kCGTextFill);
CGContextSetGrayFillColor(context, 0.0, 1.0);
CGAffineTransform myTextTransform = CGAffineTransformRotate(CGAffineTransformScale(CGAffineTransformIdentity, 1.f, -1.f ),(-1));
CGContextSetTextMatrix (context, myTextTransform);
CGContextShowTextAtPoint (context, 0, 0, "Quartz 2D", 9);
------------------------------------
The code works fine for me, but it doesn't have that line wrapping feature that I get with the "NSString drawInRect" call.
Is there anyway to get my lines of text to rotate?
Thanks for the help.
Cheers,
Mark
Mac OS X (10.5.5), iPhone