title: Why layoutIfNeeded() allows to perform animation when updating constraints?
body: <p>I have two states of <code>UIView</code>:</p>
  
  <p><img src="https://i.stack.imgur.com/iL91d.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/xbnHn.png" alt="enter image description here"></p>
  
  <p>I have animation between them using <code>@IBaction</code> for <code>button</code>:</p>
  
  <pre><code>@IBAction func tapped(sender: UIButton) {
      flag = !flag
      UIView.animateWithDuration(1.0) {
          if self.flag {
              NSLayoutConstraint.activateConstraints([self.myConstraint])
          } else {
              NSLayoutConstraint.deactivateConstraints([self.myConstraint])
          }
          self.view.layoutIfNeeded() //additional line
      }
  }
  </code></pre>
  
  <p>Animation is working <strong>only when I add additional line</strong>:</p>
  
  <p>But when I remove that line, then my <code>UIView</code> is updated but without any animation, it happens immediately.</p>
  
  <p>Why this line makes such difference? How is it working?</p>