gpt4 book ai didi

iphone - 带旋转的drawAtPoint

转载 作者:行者123 更新时间:2023-12-01 18:33:02 24 4
gpt4 key购买 nike

我无法使用 drawAtPoint 在正确的位置绘制 imageView.image .在我使用过的应用程序中CGAffineTransformMakeRotation旋转 ImageView ,但是当我想使用 UIGraphicsGetImageFromCurrentImageContext 将 imageView 保存为与其他人合并的一部分时我不知道如何让它旋转.. 我所做的只是旋转 180 度。这是我用来将其与另一个图像合并的代码。

UIGraphicsBeginImageContext(imageView.bounds.size); 

[imageView.image drawAtPoint:CGPointMake(-40,0)];
[topView.image drawAtPoint:CGPointMake(0,160)];

UIImage *mergedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

所以我的问题是:我如何 drawAtPoint旋转 180 度或 3.14159265 弧度?

提前致谢。

最佳答案

您可以对图像内容应用变换,因此所有后续绘画操作都将使用该变换进行绘制,例如(未经测试)

UIGraphicsBeginImageContext(size);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextRotateCTM(c, M_PI/6);
[image drawAtPoint:CGPointZero];
...

关于iphone - 带旋转的drawAtPoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6048249/

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