How do I make a UIImage (screenshot) from the contents of a popover?
-
27-10-2019 - |
Question
I'm presenting a popover from a button, in the popover users can make a drawing. I'd like to capture this drawing as a UIImage.
At the moment the drawing is a simple line drawing using UIBezierPath, similar to this tutorial: http://soulwithmobiletechnology.blogspot.com/2011/05/uibezierpath-tutorial-for-iphone-sdk-40.html
Thanks in advance for the help!
Solution
If someone else comes across this. If you can't find renderInContext just
#import <QuartzCore/QuartzCore.h>
OTHER TIPS
for an actual copy paste solution:
#import <QuartzCore/QuartzCore.h>
- (UIImage*) screenShot {
UIGraphicsBeginImageContext(_view.bounds.size);
[_view.layer renderInContext: UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); //renders view to an image
UIGraphicsEndImageContext();
return viewImage;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow