title: iOS 13 setting status bar background color
body: <p>I used to have the below code but after upgrading to iOS 13, I have got the error below:</p>
  
  <pre><code>UIApplication.shared.statusBarView?.backgroundColor = UIColor(red: 94/225, green: 64/255, blue:204/255, alpha: 1.0)
  </code></pre>
  
  <p>App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'</p>
  
  <p>How could the background color of status bar be set now?</p>
  
  <p>The warning message mention about using statusBarManager and so I did something like this, yet I could not get it to work.</p>
  
  <pre><code>var statusBar = UIView()
  
      if #available(iOS 13.0, *) {
          statusBar = UIView(frame: UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame ?? CGRect.zero)
          statusBar.backgroundColor = UIColor.red
          UIApplication.shared.keyWindow?.addSubview(statusBar)
      } else {
          //ios 12 and below
          UIApplication.shared.statusBarView?.backgroundColor = UIColor(red: 94/225, green: 64/255, blue:204/255, alpha: 1.0)
      }
  </code></pre>