AutoLayout面试题记录-用NSLayoutConstraint写动画

import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var topY: NSLayoutConstraint!
    @IBOutlet weak var destinationBtn: UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        

    }

    @IBAction func click(_ sender: UIButton) {

        UIView.animate(withDuration: 1, delay: 0, options: UIViewAnimationOptions.curveEaseInOut, animations: {
            self.topY.constant = 200
            self.view.layoutIfNeeded()
        }) { (true) in
            
        }
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

storyboard中2个按钮,一个点击,一个移动动画用的

此文仅为鄙人学习笔记之用,朋友你来了,如有不明白或者建议又或者想给我指点一二,请私信我。liuw_flexi@163.com/QQ群:582039935. 我的gitHub: (学习代码都在gitHub) https://github.com/nwgdegitHub/
原文地址:https://www.cnblogs.com/liuw-flexi/p/7522366.html