我展示了一个按钮的弹出窗口,用户可以在弹出窗口中绘制。我想将此绘图捕获为UIImage。
目前,使用UIBezierPath绘制的图形是一个简单的直线图,类似于本教程:http://soulwithmobiletechnology.blogspot.com/2011/05/uibezierpath-tutorial-for-iphone-sdk-40.html
提前感谢您的帮助!
如果其他人遇到此问题。如果找不到renderInContext#import <QuartzCore/QuartzCore.h>
对于实际的复制粘贴解决方案:
#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;
}