我真的希望你能帮助我。 在我的项目中,我有一个WebView打开一个特定的页面和一个按钮,我需要做的是截取整个网页的截图,并在用户按下按钮时将其导出为图像或pdf。
以下是我在ViewCnotroller中的内容:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var WebView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = URL (string: "https://www.google.com")
QuizView.loadRequest(URLRequest(url: url!))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func ShotBtn(_ sender: Any) {
let activityVC = UIActivityViewController(activityItems: [self.WebView.image], applicationActivities: nil)
}
}
现在我知道UIWebView类型的值没有成员图像,但我发现的唯一例子是使用UIImage insted WebView。
我看到了这个答案Get UIWebView content and convert it to image,但我一直在寻找swft 4中的内容
我该怎么办? 三江源