操纵手势后从UIImageView保存图像

问题描述:

我试图通过移动,捏合和旋转手势来保存图像.

I'm trying to save the image after manipulating it with move, pinch and rotate gestoures.

无论尝试什么,我得到的都是真实的图像,

All I get is the real image no matter what I tried,

我尝试在UIView容器和UIIMageView上使用UIGraphicsBeginImageContextWithOptions,但没有成功.

I tried with UIGraphicsBeginImageContextWithOptions on the UIView container and on the UIIMageView without success.

希望有人可以对此提供帮助.

Hope someone can help on this one.

谢谢

留住

您可以尝试以下操作:

UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0);

CGContextConcatCTM(UIGraphicsGetCurrentContext(), imageView.transform);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];

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

这是假设您的imageView通过对其应用的CGAffineTransform进行了转换.

This is assuming your imageView is transformed by means of a CGAffineTransform applied to it.