Avatar ·

Animation of constraint change in Swift: how to make it smooth?

Hello everyone! I'm a beginner in iOS development and using Swift + Xcode 6. I encountered a problem: I need to animate the height change of a UIView. I added a height constraint in Interface Builder (IBOutlet), and in code I change its constant: ```swift @IBOutlet weak var myViewHeightConstraint: NSLayoutConstraint! @IBAction func toggleView(sender: UIButton) { if myViewHeightConstraint.constant == 100 { myViewHeightConstraint.constant = 200 } else { myViewHeightConstraint.constant = 100 } } ``` But when I press the button, the size changes instantly, without animation. I tried wrapping this in `UIView.animate(withDuration:animations:)`, but nothing happens. How to properly animate a constraint change? Do I need to call something additionally? Thanks in advance! P.S.