Pergunta

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!

Foi útil?

Solução

If someone else comes across this. If you can't find renderInContext just #import <QuartzCore/QuartzCore.h>

Outras dicas

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;

}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top