Note: How to Animate with Auto Layout Constraints

Author: Sean Allen Video URL: How to Animate with Auto Layout Constraints Introduction: In this video we walk through how to create animations by adjusting the auto layout constraints and object, such as a UIImageView, UIButton, etc… This tutorial was done in Swift 4.2 and Xcode 10.

Add IBoutlet of constraints by ctrl+drag

Add IBoutlet of constraints

Ways to animate with auto layout constraints

Add IBoutlet of the target constraint, and change its values, then update.

    @IBOutlet weak var logoTopConstraint: NSLayoutConstraint!
    func animateLogoTop() {
        logoTopConstraint.constant = 50
        UIView.animate(withDuration: 0.4) {

Change the variable of programmed constraints and update

    func animateStartButtonCenter() {
        startButtonCenterYConstraint.constant =
        UIView.animate(withDuration: 0.4, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 4, options: .curveEaseOut, animations: {
        }, completion: nil)


Fill in your details below or click an icon to log in: 徽标

您正在使用您的 账号评论。 注销 /  更改 )

Twitter picture

您正在使用您的 Twitter 账号评论。 注销 /  更改 )

Facebook photo

您正在使用您的 Facebook 账号评论。 注销 /  更改 )

Connecting to %s

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理