drawAtPoint与旋转

时间:2011-05-18 16:53:37

标签: iphone objective-c ios rotation cgpoint

我无法使用drawAtPoint将imageView.image绘制到正确的位置。在应用程序中,我使用CGAffineTransformMakeRotation来旋转图像视图,但是当我想使用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弧度?

提前致谢。

1 个答案:

答案 0 :(得分:4)

您可以对图像内容应用变换,因此将使用该变换绘制所有后续绘制操作,例如(另)

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