article

Tuesday, May 4, 2021

SwiftUI implement WebView(WebKit)

SwiftUI implement WebView(WebKit)
//
//  ViewController.swift
//  web
//
//  Created by Cairocoders
//

import UIKit
import WebKit

class ViewController: UIViewController {

    let webView = WKWebView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(webView)
        
        guard let url = URL(string: "https://tutorial101.blogspot.com") else {
            return
        }
        webView.load(URLRequest(url: url))
    }
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        webView.frame = view.bounds
    }


}

Related Post