iOS NSLayoutConstraint Fixed Width using constraintWithItem

前端 未结 5 492
無奈伤痛
無奈伤痛 2021-02-02 06:37

I\'d like to set a constraint to give a UIButton a fixed (constant) width programmatically. I know I can do this with constraintsWithVisualFormat, but I\'ve been using constrain

5条回答
  •  情话喂你
    2021-02-02 07:00

    Rather than looking for an explicit height (28), a better idea would be to look for a height constraint…

    loginButton.constraints.first(where: { $0.firstAttribute == .height })?.constant = 40
    

提交回复
热议问题