title: Swift4: How to set top constraint when you have a navigation controller?
body: <p><a href="https://i.stack.imgur.com/a1Ngn.png" rel="nofollow noreferrer">screenshot</a>
  I created a view where I put an image view and a view. I  programmatically added constraints to both my views so that they are perfectly centred in each screen I chose, but when I launch the app on iPhone XSMax I get a white bar in the bottom. So I guess I'm making a mistake with my top constraint, how do I handle top constraints when I have a navigation bar?</p>
  
  <pre><code> func imageAndColorView() {
  
      view.addSubview(imageView)
      view.addSubview(colorView)
      imageView.translatesAutoresizingMaskIntoConstraints = false
  
      imageView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
      imageView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
      imageView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
      imageView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
  
      colorView.translatesAutoresizingMaskIntoConstraints = false
      colorView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
      colorView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
      colorView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
      colorView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
  
      imageView.image = UIImage(named: BackgroundImageKey)
      view.sendSubviewToBack(imageView)
      view.insertSubview(colorView, aboveSubview: imageView)
  }
  </code></pre>
  
  <p>Yes, I called this in my viewDidLoad.</p>