gpt4 book ai didi

ios - 如何使用 CGAffineTransformMakeRotation?

转载 作者:IT王子 更新时间:2023-10-29 07:52:03 26 4
gpt4 key购买 nike

enter image description here

我想使用 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 需要以弧度为单位的角度,而不是度数。

#define DEGREES_TO_RADIANS(x) (M_PI * (x) / 180.0)
...

CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(45));

关于ios - 如何使用 CGAffineTransformMakeRotation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5725099/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com