Saving Image from UIImageView after manipulating G

2019-08-09 03:46发布

问题:

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,

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

Hope someone can help on this one.

Thanks,

Itay

回答1:

You could try with this:

UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0);

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

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

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