0

我正在从一个按钮呈现一个弹出窗口,用户可以在弹出窗口中进行绘图。我想将此绘图捕获为 UIImage。

目前绘图是使用 UIBezierPath 绘制的简单线条,类似于本教程:http ://soulwithmobiletechnology.blogspot.com/2011/05/uibezierpath-tutorial-for-iphone-sdk-40.html

在此先感谢您的帮助!

4

2 回答 2

0

如果其他人遇到这种情况。如果你找不到 renderInContext 只是 #import <QuartzCore/QuartzCore.h>

于 2013-07-23T07:03:13.313 回答
0

对于实际的复制粘贴解决方案:

#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;

}
于 2013-07-23T07:17:58.390 回答