문제

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;

}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top