How do I make a UIImage (screenshot) from the contents of a popover?
-
27-10-2019 - |
문제
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!
해결책
If someone else comes across this. If you can't find renderInContext just
#import <QuartzCore/QuartzCore.h>
다른 팁
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;
}
제휴하지 않습니다 StackOverflow