title: Animating constraints for iOS xibs
body: <p>I have been reading a few posts about animating when working with xibs in iOS development. Mostly what I read was to not animate the frame but instead animate the constraints. I have constrained a label to be in the centre of the view on start up, then I animate it up and present a login textfield (The typical login stuff you see).</p>
  
  <p><img src="https://i.stack.imgur.com/Uk6L5.png" alt="enter image description here"></p>
  
  <p>I did this animating the frame and of course when I click on the the text field, the view applies the original constraint to the "My Title" label and pushes it back to its original centre location.</p>
  
  <p><img src="https://i.stack.imgur.com/HrBY7.png" alt="enter image description here"></p>
  
  <p>How can I remove the centring constraint and add a new constraint to in-force a space from the top programmatically?</p>
  
  <p>Here is my animation code:</p>
  
  <pre><code>[UIView animateWithDuration: 0.8
                        delay: 1.0
       usingSpringWithDamping: 0.8
        initialSpringVelocity: 0.5
                      options: UIViewAnimationOptionCurveEaseOut
                   animations: ^{
                       self.titleLabel.frame = CGRectOffset(self.titleLabel.frame, 0, -self.view.frame.size.height/4.5);
                   } completion: ^(BOOL finished) {
                       if (finished)
                       {
                           [UIView animateWithDuration: 0.8
                                                 delay: 0.3
                                usingSpringWithDamping: 0.8
                                 initialSpringVelocity: 0.5
                                               options: UIViewAnimationOptionCurveEaseInOut
                                            animations: ^{
  
                                                self.userIdTextField.alpha = 1.0;
                                                self.userPasswordTextField.alpha = 1.0;
                                                self.loginButton.alpha = 1.0;
  
                                            } completion: ^(BOOL finished) {
                                            }];
                       }
                   }];
  </code></pre>