title: iOS 11 UINavigationBar UISearchBar and UIBarButtonItem overlap
body: <p>In iOS 11, if you set a UISearchBar to be titleView of the navigationItem. Then add / remove UIBarButtonItem to navigationItem.leftBarButtonItems. The UIBarButtonItem will overlap with the UISearchBar.</p>
  
  <p><a href="https://i.stack.imgur.com/hdyzL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hdyzL.jpg" alt="enter image description here"></a>
  Steps to reproduce:</p>
  
  <ol>
  <li>New single view Xcode project</li>
  <li>Embed ViewController in UINavigationController in storyboard</li>
  <li><p>Modify ViewController.swift like this</p>
  
  <pre><code>class ViewController: UIViewController {
      let button = UIBarButtonItem(barButtonSystemItem: .add, target: nil, action: nil)
      override func viewDidLoad() {
          super.viewDidLoad()
          let searchBar = UISearchBar()
          searchBar.searchBarStyle = .minimal
          navigationItem.titleView = searchBar
      }
  
      override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
          super.traitCollectionDidChange(previousTraitCollection)
          if traitCollection.horizontalSizeClass == .regular {
              navigationItem.leftBarButtonItem = button
          } else {
              navigationItem.leftBarButtonItem = nil
          }
      }
  }
  </code></pre></li>
  </ol>
  
  <p>Environment: Xcode 9.2, iOS 11.2.2</p>
  
  <p>My question is: is there a way for the UINavigationBar to layout items correctly or have I done something wrong here? Thanks!</p>