Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 向WKWebView添加加载栏并选择其颜色_Ios_Swift_Xcode_Wkwebview - Fatal编程技术网

Ios 向WKWebView添加加载栏并选择其颜色

Ios 向WKWebView添加加载栏并选择其颜色,ios,swift,xcode,wkwebview,Ios,Swift,Xcode,Wkwebview,我正在尝试将加载栏添加到我的WebView页面顶部。我将在哪里添加代码。也可以更改此加载条的颜色吗 如果不需要自定义视图,则可以使用SFSafariViewController来实现这一点。使用下面的代码 if let url = URL(string: "https://jwelsh19.wixsite.com/countryday") { let config = SFSafariViewController.Configuration() config.entersRead

我正在尝试将加载栏添加到我的WebView页面顶部。我将在哪里添加代码。也可以更改此加载条的颜色吗


如果不需要自定义视图,则可以使用SFSafariViewController来实现这一点。使用下面的代码

if let url = URL(string: "https://jwelsh19.wixsite.com/countryday") {
    let config = SFSafariViewController.Configuration()
    config.entersReaderIfAvailable = true

    let vc = SFSafariViewController(url: url, configuration: config)
    present(vc, animated: true)
}
如果不想使用SFSafariViewController,请将UIProgressbar添加到webview容器视图中,观察webview进度并相应地更新UIProgressbar 要观察webview进度,请使用webview进度观察者

    webView.addObserver(self, forKeyPath: #keyPath(WKWebView.estimatedProgress), options: .new, context: nil)

    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
        if keyPath == "estimatedProgress" {
            progressView.progress = Float(webView.estimatedProgress)
        }
    }

由于我在这里没有看到任何与加载栏相关的代码,您是否对如何添加加载栏做了任何变通。添加自定义栏并相应地设置webview进度bar@ShauketSheikh如何将自定义栏添加到WKWebView?我确实需要自定义视图。。。是否可以将UIProgressBar添加到WKWebView?是的,您可以在WKWebView中参考UIProgressBar的此链接
    webView.addObserver(self, forKeyPath: #keyPath(WKWebView.estimatedProgress), options: .new, context: nil)

    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
        if keyPath == "estimatedProgress" {
            progressView.progress = Float(webView.estimatedProgress)
        }
    }