如何从弹出窗口的内容制作 UIImage(屏幕截图)?

发布于 2025-01-06 20:27:09 字数 348 浏览 2 评论 0 原文

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

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

预先感谢您的帮助!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

睡美人的小仙女 2025-01-13 20:27:09

如果其他人遇到这种情况。如果你找不到 renderInContext 只是
#import

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

泪之魂 2025-01-13 20:27:09

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

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

}

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;

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文