I'm quite new to Swift, I just want to show a mobile version of a site using Apple's WKWebView but on iPhone X or later where there's a notch, the status bar is not solid which doesn't look good if the website has a sticky navigation bar.
I've tried everything I could find online but nothing worked, so I thought I might post my issue here.
I would like to make the status bar solid white so it matches the sticky navigation bar.
This is my code:
import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
var webView: WKWebView!
override var prefersStatusBarHidden: Bool {
return true
}
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string:"https://www.webthat.nl")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
}
This is what I get on iPhones with a notch: