iOS 将webview 显示截取成图片

self.webview.evaluateJavaScript(
            "document.querySelector('canvas').toDataURL()",
            completionHandler: { [weak self] (data, error) in

        guard let base64 = data as? String else {
            return
        }
        guard let url = URL(string: base64), let imageData = try? Data(contentsOf: url) else {
            return
        }
        guard let image = UIImage(data: imageData) else {
            return
        }
)

你可能感兴趣的:(iOS 将webview 显示截取成图片)