title: ios swift - navigation item background turns black when going back to a screen where the navigation bar is hidden
body: <p>I thought showing a screenshot would help understand the issue a bit better.</p>
  <p>So the context is the following:</p>
  <p>I'm in a navigation controller, on the settings screen of the app (which has a navigation item) and when we tap on the back button, we go back to the main screen of the app (for which I've hidden the navigation bar in the viewWillAppear of the main screen because I'm building a custom header view myself).</p>
  <p>At soon as I tap on the back button, the navigation bar disappears immediately and I see a black rectangle appears instead until the animation to display the main screen is completed.</p>
  <p>Do you know how I can avoid having this black rectangle appear?</p>
  <p>Hope the questions makes sense.</p>
  <h1><em>Screenshots</em></h1>
  <p><strong>Here is the initial settings screen:</strong></p>
  <p><a href="https://i.stack.imgur.com/Z0lO4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Z0lO4.png" alt="enter image description here" /></a></p>
  <p><strong>When we tape on the back button, this happens... help :D</strong></p>
  <p>I know this piece of code is most likely responsible for the error, but I absolutely need to have the navigationBar hidden on the previous screen.</p>
  <p>override func viewWillAppear(_ animated: Bool) {</p>
  <pre><code>navigationController?.isNavigationBarHidden = true
  </code></pre>
  <p>}</p>
  <p><a href="https://i.stack.imgur.com/DCZ2h.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DCZ2h.png" alt="enter image description here" /></a></p>