以编程方式拍摄视图/WebView 的快照

发布于 2024-07-12 13:08:23 字数 78 浏览 8 评论 0原文

我想拍摄视图 (WebView) 的快照,或者如果不可能的话,拍摄整个屏幕的快照,以便我可以将其保存到用户的照片库中。 我想知道这是否可能。

I want to take a snapshot of a view (WebView) or, if that is not possible, the whole screen, so I can save it into the user's photo gallery. I was wondering if this is possible.

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

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

发布评论

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

评论(1

把昨日还给我 2024-07-19 13:08:23

要获取图像,您需要使用:

UIGraphicsBeginImageContext(self.bounds.size);

[theView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

然后,保存到照片库:

UIImageWriteToSavedPhotosAlbum(viewImage,nil,NULL,NULL);

To get the image, you'll want to use:

UIGraphicsBeginImageContext(self.bounds.size);

[theView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

Then, to save to the Photos Library:

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