Multiline UIButton and autolayout

后端 未结 16 1522
无人共我
无人共我 2020-12-03 13:08

I have created a view controller that looks like this:

\"enter

I want the two

16条回答
  •  没有蜡笔的小新
    2020-12-03 13:49

    add the missing constraints:

    if let label = button.titleLabel {
    
        button.addConstraint(NSLayoutConstraint(item: label, attribute: .top, relatedBy: .equal, toItem: button, attribute: .top, multiplier: 1.0, constant: 0.0))
        button.addConstraint(NSLayoutConstraint(item: label, attribute: .bottom, relatedBy: .equal, toItem: button, attribute: .bottom, multiplier: 1.0, constant: 0.0))
    }
    

提交回复
热议问题