title: Why are animated calls of UIView.isHidden = false compounded?
body: <p>As you can see I'm having trouble formulating the question. Let me try to explain:</p>
  
  <p>I'm using a search bar in my swift ios app. In order to get a desired animation effect I put it in a vertical stack view and then animate its <code>isHidden</code> property. This way search bar pushes down other children of the stack view as it animates in or pulls them up as it animates out. So far so good. </p>
  
  <p>I've noticed a behavior that I think is strange. Could be a bug or could be me not understanding how things work. Basically if I call search bar hiding method x times in a row I need to call search bar showing method x times before it would show. I'd expect to have to make just one call to show search bar regardless of how many times I called hiding method. The issue doesn't exist other way around: if I call search bar showing code x times I only need to call hiding method once for it to go away. This doesn't happen if I set <code>isHidden</code> without animating it...</p>
  
  <p>Here's a sample code and a video of the issue. I'd appreciate it if someone would help me understand this behavior.</p>
  
  <pre><code>class ViewController: UIViewController {
  
  @IBOutlet weak var searchBar: UISearchBar! {
      didSet {
          searchBar.isHidden = true
      }
  }
  
  @IBAction func showAction(_ sender: UIButton) {
      expandSearch()
  }
  
  @IBAction func hideAction(_ sender: UIButton) {
      collapseSearch()
  }
  
  private func expandSearch() {
      UIView.animate(withDuration: 0.3){
          self.searchBar.isHidden = false
      }
  }
  
  private func collapseSearch() {
      UIView.animate(withDuration: 0.3){
          self.searchBar.isHidden = true
      }
      searchBar.resignFirstResponder()
  }
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/N99QZ.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N99QZ.gif" alt="video"></a></p>