iOS NSLayoutConstraint Fixed Width using constraintWithItem

前端 未结 5 491
無奈伤痛
無奈伤痛 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 06:59

    How about using Layout Anchors?

    myView.widthAnchor.constraintEqualToConstant(29).isActive = true
    

提交回复
热议问题