title: Hide and Show UIBarButtonItem with Swift 4
body: <p>I want to hide and show my <code>UIBarButtonItem</code> but since Swift 4 and iOS 11, it doesn't work anymore. Why ?</p>
  
  <p><strong>Code for hide :</strong> </p>
  
  <pre><code>self.navigationItem.rightBarButtonItem = nil
  </code></pre>
  
  <p><strong>Code for show :</strong></p>
  
  <pre><code>self.navigationItem.rightBarButtonItem = self.barButtonItem
  </code></pre>
  
  <p><strong>Before :</strong></p>
  
  <p><a href="https://i.stack.imgur.com/sBWkO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sBWkO.png" alt="UIBarButtonItem is display"></a></p>
  
  <p><strong>During :</strong></p>
  
  <p><a href="https://i.stack.imgur.com/ZPmAB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZPmAB.png" alt="When I tap on my SearchBar"></a></p>
  
  <p><strong>After :</strong></p>
  
  <p><a href="https://i.stack.imgur.com/jFggC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jFggC.png" alt="When I click on Cancel, UIBarButtonItem not appear"></a></p>