title: Search bar not aligned next to back button in navigation bar
body: <p>I used a custom navigation controller class to remove the back button in my navigation bar, with the following:</p>
  
  <pre><code>class CustomNavigationController: UINavigationController, UINavigationControllerDelegate {
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          self.delegate = self
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
      }
  
  
      func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
  
          viewController.navigationItem.backBarButtonItem = UIBarButtonItem(title: " ", style: .plain, target: nil, action: nil)
      }
  
  }
  </code></pre>
  
  <p>In one of my VCs, I also add a search controller to the navigation bar with the following:</p>
  
  <pre><code>private func configureSearchController() {
          self.searchController = UISearchController(searchResultsController: nil)
          self.searchController.searchResultsUpdater = self
          self.searchController.delegate = self
          self.searchController.searchBar.delegate = self
  
          self.searchController.hidesNavigationBarDuringPresentation = false
          self.searchController.dimsBackgroundDuringPresentation = true
  
          self.navigationItem.titleView = searchController.searchBar
          self.definesPresentationContext = true
      }
  </code></pre>
  
  <p>However, it seems like the search bar is still being offset by some blank space where the title would be. I'd image the search bar should be aligned next to the back button, but there is the back button, space with blank title, then search bar.</p>
  
  <p><a href="https://i.stack.imgur.com/1vY0L.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1vY0L.jpg" alt="enter image description here"></a></p>
  
  <p>How can I get the search bar aligned next to the back button instead of spaced because it seems there is some room for the blank title. Also, as a note, tapping on that blank space moves me back to the previous VC, although there is no actual title there.</p>
  
  <p>EDIT:</p>
  
  <p>View hierarchy, looks like the back button container view itself takes up a good amount of space <a href="https://i.stack.imgur.com/rPo8B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rPo8B.png" alt="enter image description here"></a></p>