trying to animate a constraint in swift

后端 未结 6 1932
离开以前
离开以前 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:29

    In my case, I only updated the custom view.

    // DO NOT LIKE THIS
    customView.layoutIfNeeded()    // Change to view.layoutIfNeeded()
    UIView.animate(withDuration: 0.5) {
       customViewConstraint.constant = 100.0
       customView.layoutIfNeeded() // Change to view.layoutIfNeeded()
    }
    

提交回复
热议问题