title: Swift: Hide status bar on only one child view controller
body: <p>I have a problem when it comes to the status bar and hiding it.</p>
  
  <h1>The setup</h1>
  
  <p>I have a <strong>BaseViewController</strong> that has a slide out menu. This BaseViewController is also the root controller of the application [as set inside AppDelegate]:</p>
  
  <pre><code>window = UIWindow()
  window?.makeKeyAndVisible()
  window?.rootViewController = BaseController()
  </code></pre>
  
  <p>As soon as I select a menu item the BaseViewController is populated by the corresponding ViewController [after I embed it into a navigation controller].</p>
  
  <p>Menu item A: <strong>ViewControllerA</strong></p>
  
  <p>Menu item B: <strong>ViewControllerB</strong></p>
  
  <p>Menu item C: <strong>ViewControllerC</strong></p>
  
  <p>Say that I select the Menu Item A (the following code takes place inside BaseViewController):</p>
  
  <pre><code>let activeVC = UINavigationController(rootViewController: ViewControllerA())
  view.addSubview(activeVC.view)
  addChild(activeVC)
  </code></pre>
  
  <p>When I select another menu item (say item B), I first remove the previous active view controller (in this case item A) and then I add the ViewControllerB the same way as I did with ViewControllerA:</p>
  
  <p>This is how I remove the previous active view controller:</p>
  
  <pre><code>activeVC.view.removeFromSuperview()
  activeVC.removeFromParent()
  </code></pre>
  
  <h1>Manipulating the status bar in each view controller separately:</h1>
  
  <p>I set the <strong>View controller-based status bar appearance</strong> to YES in <strong>plist</strong> control the appearance of the status bar in every view controller:</p>
  
  <p><a href="https://i.stack.imgur.com/cxFzg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cxFzg.png" alt="enter image description here"></a></p>
  
  <p>Then I go into the ViewController I want to hide the status bar and I add the following code:</p>
  
  <pre><code>override var prefersStatusBarHidden: Bool {
      return true
  }
  </code></pre>
  
  <h1>The problem</h1>
  
  <p>If I want to hide the status bar inside any of the ViewController A, B, or C, I can't. Overriding the prefersStatusBarHidden and setting it to "true" will do nothing.</p>
  
  <p>If I override the prefersStatusBarHidden and setting it to "true" into the BaseViewController, then the BaseViewController and also any of the ViewController A, B, and C will hide the status bar.</p>
  
  <h1>What I want</h1>
  
  <p>I want to be able to hide the status bar on ViewControllerB without hiding it on the rest. Also a million dollars, but I will settle with the solution!</p>
  
  <p>Thanks in advance!</p>