I want to draw text use Quartz 2D. The "menu" direction is wrong. I want "Menu" still readable and have 45 degree with X-axis. Below is my code:
CGContextSelectFont(context, "Arial", 12, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetRGBFillColor(context, 0, 0, 0, 1); // 6
CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));
CGContextSetTextMatrix(context, CGAffineTransformMakeRotation(45));
CGContextShowTextAtPoint(context,10, 10, "Menu", 4);
CGAffineTransformMakeRotation expects angle in radians, not in degrees.
#define DEGREES_TO_RADIANS(x) (M_PI * (x) / 180.0)
...
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(45));
Sandeep Saurabh
[view setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
来源:https://stackoverflow.com/questions/5725099/how-to-use-cgaffinetransformmakerotation