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!)
}
}