title: setNeedsLayout vs. setNeedsUpdateConstraints and layoutIfNeeded vs updateConstraintsIfNeeded
body: <p>I know that the auto layout chain consists in basically 3 different process.</p>
  
  <ol>
  <li>updating constraints</li>
  <li>layout views (here is where we get calculation of frames)</li>
  <li>display</li>
  </ol>
  
  <p>What's is not totally clear to me is the inner difference between <code>-setNeedsLayout</code> and <code>-setNeedsUpdateConstraints</code>. From Apple Docs:<br> </p>
  
  <p><a href="https://developer.apple.com/reference/uikit/uiview/1622601-setneedslayout" rel="noreferrer"><strong>setNeedsLayout</strong></a></p>
  
  <blockquote>
    <p>Call this method on your application’s main thread when you want to
    adjust the layout of a view’s subviews. This method makes a note of
    the request and returns immediately. Because this method does not
    force an immediate update, but instead waits for the next update
    cycle, you can use it to invalidate the layout of multiple views
    before any of those views are updated. This behavior allows you to
    consolidate all of your layout updates to one update cycle, which is
    usually better for performance.
     <br></p>
  </blockquote>
  
  <p><a href="https://developer.apple.com/reference/uikit/uiview/1622450-setneedsupdateconstraints" rel="noreferrer"><strong>setNeedsUpdateConstraints</strong></a></p>
  
  <blockquote>
    <p>When a property of your custom view changes in a way that would impact
    constraints, you can call this method to indicate that the constraints
    need to be updated at some point in the future. The system will then
    call updateConstraints as part of its normal layout pass. Updating
    constraints all at once just before they are needed ensures that you
    don’t needlessly recalculate constraints when multiple changes are
    made to your view in between layout passes.</p>
  </blockquote>
  
  <p>When I want to animate a view after modifying a constraint and animate the changes I usually call for instance:</p>
  
  <pre><code>[UIView animateWithDuration:1.0f delay:0.0f usingSpringWithDamping:0.5f initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
          [self.modifConstrView setNeedsUpdateConstraints];
          [self.modifConstrView layoutIfNeeded];
      } completion:NULL];
  </code></pre>
  
  <p>I've found out that if I use <code>-setNeedsLayout</code> instead of <code>-setNeedsUpdateConstraints</code> everything work as expected, but if I change <code>-layoutIfNeeded</code> with <code>-updateConstraintsIfNeeded</code>, the animation won't happen.<br>
  I've tried to make my own conclusion:</p>
  
  <ul>
  <li><code>-updateConstraintsIfNeeded</code> only update constraints but doesn't force the layout to come into the process, thus original frames are still preserved</li>
  <li><code>-setNeedsLayout</code> calls also <code>-updateContraints</code> method</li>
  </ul>
  
  <p>So when is ok to use one instead of the other? and about the layout methods, do I need to call them on the view that has a change in a constraint or on the parent view?</p>