title: swift - Navigation Bar Title Position
body: <p>I am wondering how to bring the title to the center again.</p>
  
  <p>I have a search button on the right side, and when you click it, a search box will appear.
  The title is being moved to the left, but when I close the search box, the title is not going back to it's original location.</p>
  
  <p><a href="http://i.stack.imgur.com/J7Z6F.png" rel="nofollow">Here is a screenshot</a></p>
  
  <p>You can see the on the third part, the title does not go back to the center.</p>
  
  <p>Your help is really appreciated.</p>
  
  <p>Thank you!</p>
  
  <p>Edit:
  Here is the code:</p>
  
  <pre><code>func searchBtn(){
      searchBars.hidden = false
      search = UIBarButtonItem(customView: searchBars)
      var cancel = UIBarButtonItem(barButtonSystemItem: .Cancel, target: self, action: #selector(cancelSearch))
      self.navigationItem.rightBarButtonItems = [cancel,search]
      searchBars.becomeFirstResponder()
  }
  func cancelSearch(){
  
      searchBars.hidden = true
      self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Search, target: self, action: #selector(searchBtn))
  }
  </code></pre>