trying to animate a constraint in swift

后端 未结 6 1953
离开以前
离开以前 2020-11-29 16:00

I have a UITextField that I want to enlarge its width when tapped on. I set up the constraints and made sure the constraint on the left has the lower priority t

6条回答
  •  盖世英雄少女心
    2020-11-29 16:28

    Watch this.

    The video says that you need to just add self.view.layoutIfNeeded() like the following:

    UIView.animate(withDuration: 1.0, animations: {
           self.centerX.constant -= 75
           self.view.layoutIfNeeded()
    }, completion: nil)
    

提交回复
热议问题