swift - WKWebView
Summary
- 在APP中嵌入一个网页,相当于一个内置的浏览器,固定访问我们的服务。
Demo
import UIKit
import WebKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.view.backgroundColor = UIColor.gray
var webView: WKWebView?
webView = WKWebView(frame:CGRect(x:0, y:0, width:UIScreen.main.bounds.size.width, height:UIScreen.main.bounds.size.height))
let rul = URL.init(string:("https://www.duchaoqun.cn/"))
let request = URLRequest(url:rul!)
webView?.load(request)
self.view.addSubview(webView!)
}
}
本文来自博客园,作者:duchaoqun,转载请注明原文链接:https://www.cnblogs.com/duchaoqun/p/12928460.html