| | |
| | | private(set) var url:String? |
| | | private(set) var htmlText:String? |
| | | private(set) var baseUrl:URL? |
| | | private var showHelp = false |
| | | private var progressView = UIProgressView() |
| | | private let jsCode = """ |
| | | var meta = document.createElement('meta');" |
| | |
| | | public var tintColor = UIColor.blue |
| | | private var subVC:Bool = false |
| | | |
| | | public convenience init(url:String) { |
| | | public convenience init(url:String,showHelp:Bool = false) { |
| | | self.init() |
| | | self.url = url |
| | | self.showHelp = showHelp |
| | | } |
| | | |
| | | public convenience init(type:AgreementType,subVC:Bool = false){ |
| | |
| | | |
| | | public override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | |
| | | |
| | | if showHelp{ |
| | | let btn = UIButton(type: .custom) |
| | | btn.setTitle("我的助力", for: .normal) |
| | | btn.setTitleColor(UIColor(hexString: "#353535"), for: .normal) |
| | | btn.titleLabel?.font = .systemFont(ofSize: 15) |
| | | btn.addTarget(self, action: #selector(myHelpAction), for: .touchUpInside) |
| | | navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn) |
| | | } |
| | | |
| | | |
| | | let config = WKWebViewConfiguration() |
| | | let userScript = WKUserScript(source: jsCode, injectionTime: .atDocumentStart, forMainFrameOnly: true) |
| | |
| | | } |
| | | } |
| | | |
| | | @objc func myHelpAction(){ |
| | | let vc = WebVC(url: ShareUrl + "/ranking/recommend?userId=\(UserViewModel.getAvatarInfo().id)") |
| | | vc.title = "我的助力" |
| | | push(vc: vc) |
| | | } |
| | | |
| | | deinit { |
| | | webView?.removeObserver(self, forKeyPath: "estimatedProgress") |
| | | } |