// // CommonWebViewViewController.swift // xingchuangke // // Created by Virgil on 2019/3/27. // Copyright © 2019 Virgil. All rights reserved. // import UIKit class CommonWebViewViewController: BaseViewController { /// 0 url地址 1:html内容 var sourceType = 0 var url = "" var strTitle = "" var strContent = "" lazy var wkWebView = { () -> WKWebView in let config = WKWebViewConfiguration.init() let wkWebView = WKWebView.init(frame: CGRect.zero, configuration: config) return wkWebView }() override func viewDidLoad() { super.viewDidLoad() self.setNavBackgroud(isWhite: false) initNavLeftBackButton() self.title = strTitle wkWebView.frame = self.view.bounds self.view.addSubview(wkWebView) if sourceType == 1 { wkWebView.loadHTMLString(strContent, baseURL: nil) } else { wkWebView.load(NSURLRequest(url: NSURL(string: url)! as URL) as URLRequest) } // Do any additional setup after loading the view. } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.setNavBackgroud(isWhite: true) } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "CommonWebViewViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ }