//
//  CCWebController.swift
//  SwiftProject
//
//  Created by mac on 2024/1/30.
//

import UIKit

import UIKit
import WebKit

class CCWebController: BaseController, WKNavigationDelegate {
    
    var webView: WKWebView!
    var urlString: String = ""
    var titleValue:String?
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        self.titleLab?.width = 200
        self.setNavgaionTitle(string:titleValue ?? "")
        self.titleLab?.sizeToFit()
        // 创建 WKWebView
        webView = WKWebView()
        view.addSubview(webView)
        webView.navigationDelegate = self
        webView.translatesAutoresizingMaskIntoConstraints = false
        webView.frame = self.view.bounds
        
        // 加载指定的 URL
        if let url = URL(string: urlString) {
            let request = URLRequest(url: url)
            webView.load(request)
        }
    }
    
    // WKNavigationDelegate 方法：网页加载完成时调用
    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        
//        self.setNavgaionTitle(string: webView.title!)
    }
}
