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

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM