zoukankan      html  css  js  c++  java
  • swift 加载网页 添加进度条

        /// 进度条:只在活动页展示
        fileprivate lazy var progressView:UIProgressView = UIProgressView()
        
        /// 进度条高度
        private var progressViewHeight:NSLayoutConstraint?
    
    
    //设置监听
      webView.addObserver(self, forKeyPath: "estimatedProgress", options: .new, context: nil)
    
    //设置进度条高度约束
            progressViewHeight = progressView.heightAnchor.constraint(equalToConstant: 2)
            progressViewHeight?.isActive = true
    
                if #available(iOS 11.0, *) {
                    progressView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true
                } else {
                    progressView.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 0).isActive = true
                }
    
    
    
    
    extension JYWebViewController: WKUIDelegate, WKNavigationDelegate,WKScriptMessageHandler {
    
        ///监听进度
        override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
            if (keyPath == "estimatedProgress") {
                progressView.progress = Float(self.webView.estimatedProgress)
            }
        }
        
        ///完成
        func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
            self.webLoadSuccess()
            progressViewHeight?.constant = 0
        }
    }
  • 相关阅读:
    Unity3D GUI图形用户界面系统
    Unity3D 自动寻路入门指南
    Unity3D 导航网格自动寻路(Navigation Mesh)
    拓展通用的冒泡排序方法
    DoTween 应用设置
    DoTween 教程
    Unity3D 脚本手册
    unity3d中获得物体的size
    Unity自动寻路Navmesh之高级
    C# 代码页获取input的值
  • 原文地址:https://www.cnblogs.com/qingzZ/p/11091265.html
Copyright © 2011-2022 走看看