How to animate a UIView with constraints in Swift?

前端 未结 5 786
悲哀的现实
悲哀的现实 2020-12-08 06:20

In my contrived example, I have the following single view:

\"enter

As you can

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 07:01

    For me the best way for animate Swift 3 & 4

    self.constraint.constant = -150
    
    UIView.animate(withDuration: 0.45) { [weak self] in
        self?.view.layoutIfNeeded()
    }
    

提交回复
热议问题