以编程方式拍摄视图/WebView 的快照 [英] Take snapshot of view / WebView programmatically

查看:24
本文介绍了以编程方式拍摄视图/WebView 的快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想拍摄一个视图 (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.

推荐答案

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

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

UIGraphicsBeginImageContext(self.bounds.size);

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

UIGraphicsEndImageContext();

然后,保存到照片库:

UIImageWriteToSavedPhotosAlbum(viewImage,nil,NULL,NULL);

这篇关于以编程方式拍摄视图/WebView 的快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆