title: How I can show/hide view inside another view with height changing of root swift?
body: <p>I have two views one inside another, it looks like picture below:</p>
  <p><a href="https://i.stack.imgur.com/AgRnF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AgRnF.png" alt="enter image description here" /></a></p>
  <p>when I press on orange arrow I would like to show/hide view above grey line and grey line too. I did it by such way:</p>
  <pre><code>@objc func showHide(tapGestureRecognizer: UITapGestureRecognizer)
      {
          let tappedImage = tapGestureRecognizer.view as! UIImageView
          UIView.animate(withDuration: 0.2, animations: { () -&gt; Void in
              self.jobDataView.isHidden = !self.jobDataView.isHidden
              
              self.view.layoutIfNeeded()
          })
          
          tappedImage.image = self.jobDataView.isHidden ? UIImage(systemName: &quot;arrow.down&quot;):UIImage(systemName: &quot;arrow.up&quot;)
      }
  </code></pre>
  <p>and my view above gray line can be hidden and shown. But root view doesn't change its' height and it has similar sizes before and after btn click. I tried to add constraint of height, but I it didn't solve my problem. Maybe someone knows how to solve my problem?</p>