How do I animate a NSLayoutConstraint in Swift?

后端 未结 2 1451
情话喂你
情话喂你 2020-12-11 00:52

I would like to animate an UIImageView. I declared a NSLayoutConstraint in viewDidLoad and used this code:

UIView.animate(withDurat         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-11 01:41

    Please set your constraint in viewDidAppear and try below correction

    myConstant = 100
    myConstraint.constant = myConstant
    UIView.animateWithDuration(1, animations: {
    self.view.layoutIfNeeded()
    }, completion: {finished in })
    

提交回复
热议问题