如何使用CGAffineTransformMakeRotation?

在这里输入图像说明

我想绘制文本使用Quartz 2D。 “菜单”方向是错误的。 我想“菜单”仍然可读,并与X轴有45度。 以下是我的代码:

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期望以弧度为单位的angular度,而不是度数。

 #define DEGREES_TO_RADIANS(x) (M_PI * (x) / 180.0) ... CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(45)); 
 [view setTransform:CGAffineTransformMakeRotation(M_PI / 2)];