27 cocoa-touch core-graphics quartz-2d ios

我想用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);
Run Code Online (Sandbox Code Playgroud)
Kri*_*dra 114
CGAffineTransformMakeRotation需要以弧度为单位的角度,而不是度数.
#define DEGREES_TO_RADIANS(x) (M_PI * (x) / 180.0)
...
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(45));
Run Code Online (Sandbox Code Playgroud)
小智 5
[view setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
41527 次 |
| 最近记录: |