title: Change background color of status bar
body: <p>I have a very simple web view project which just loads a website. There is a bug though, the website content is showing in the status bar if I scroll down. </p>
  
  <p><img src="https://i.stack.imgur.com/oARFQ.png" width="200"></p>
  
  <p>I read that this is because the background color of the ViewController is set to be transparent, how can I change it to another color?</p>
  
  <p>I tried it like this:</p>
  
  <pre><code>let color = UIColor.black;
  self.view.backgroundColor = color
  </code></pre>
  
  <p>But nothing changes</p>
  
  <p>Whole Code:</p>
  
  <p><strong>ViewController.swift</strong></p>
  
  <pre><code>import UIKit
  import WebKit
  
  class ViewController: UIViewController, WKNavigationDelegate {
  
      @IBOutlet var webView: WKWebView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // 1  The webView loads the url using an URLRequest object.
          let url = URL(string: "https://www.blizz-z.de/")!
  
          webView.load(URLRequest(url: url))
  
          // 2  A refresh item is added to the toolbar which will refresh the current webpage.
          let refresh = UIBarButtonItem(
              barButtonSystemItem: .refresh,
              target: webView,
              action: #selector(webView.reload)
          )
  
          toolbarItems = [refresh]
          navigationController?.isToolbarHidden = true
          navigationController?.isNavigationBarHidden = true
  
      }
  
      override func loadView() {
          webView = WKWebView()
          webView.navigationDelegate = self
          view = webView
          let color = UIColor.black;
          self.view.backgroundColor = color
      }
  
      func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
          title = webView.title
      }
  
  
  
  }
  </code></pre>
  
  <p>I could just disable the status bar with the following code to fix the bug, but I try to keep it:</p>
  
  <pre><code>override var prefersStatusBarHidden: Bool {
      return true
  }
  </code></pre>