As mentioned in the comments, you should not manually modify frames when you have autolayout constraints installed. Instead you need to change your constraints to reflect the animation's end result.
The following is a minimal working example. It creates a button and a text field and initially positions the text field 58 points below the end of the button. When you tap the button, the constant on the text field's top spacing constraint is decreased from 58 to 8 to move the text field up.
class ViewController: UIViewController {
var textFieldTopSpacingConstraint: NSLayoutConstraint?
override func viewDidLoad() {
super.viewDidLoad()
// Create the button
let button = UIButton.buttonWithType(.System) as! UIButton
button.setTranslatesAutoresizingMaskIntoConstraints(false)
button.setTitle("Tap me!", forState: .Normal)
button.addTarget(self, action: "buttonTapped", forControlEvents: .TouchUpInside)
view.addSubview(button)
// Create the text field
let textField = UITextField()
textField.placeholder = "Enter text here"
textField.setTranslatesAutoresizingMaskIntoConstraints(false)
view.addSubview(textField)
let views: [NSObject: AnyObject] = ["button": button, "textField": textField]
// Layout the button
view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-[button]-|", options: nil, metrics: nil, views: views))
view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-20-[button(44)]", options: nil, metrics: nil, views: views))
// Layout the text field and remember its top spacing constraint
view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-[textField]-|", options: nil, metrics: nil, views: views))
textFieldTopSpacingConstraint = NSLayoutConstraint(item: textField, attribute: .Top, relatedBy: .Equal,
toItem: button, attribute: .Bottom, multiplier: 1, constant: 58) // The text field starts 58 points below the end of the button
view.addConstraint(textFieldTopSpacingConstraint!)
}
func buttonTapped() {
// Change to constant on the top spacing constraint to move the text field up
UIView.animateWithDuration(0.5) {
self.textFieldTopSpacingConstraint?.constant = 8 // The text field now starts 8 points below the end of the button
self.view.layoutIfNeeded()
}
}
}
When you have your constraints set up through Interface Builder you can create an outlet for the top spacing constraint in your view controller and use that to modify the text field's top space.