Я новичок в autolayout, так как в моей проблеме, когда текст uilabel увеличивает другую метку с текстом nothing
, исчезает, когда текст маленький, он появляется
Код
// first label
let label = UILabel(frame: CGRect(x: 0 , y: 0, width: 10, height: 50))
label.text = "Lorem ipsum dolor sit amet"
label.numberOfLines = 0
view.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint(item: label, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leadingMargin, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: label, attribute: .trailing, relatedBy: .equal, toItem: view, attribute: .trailingMargin, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint(item: label, attribute: .top, relatedBy: .equal, toItem: view, attribute: .topMargin, multiplier: 1.0, constant: 0.0).isActive = true
// end of first label
// label1
let label1 = UILabel(frame: CGRect(x: 0, y: 0, width: 10, height: 50))
label1.text = "nothing"
label1.numberOfLines = 0
view.addSubview(label1)
label1.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint(item: label1, attribute: .leading, relatedBy: .equal, toItem: label, attribute: .leadingMargin, multiplier: 1.0, constant: label.intrinsicContentSize.width).isActive = true
NSLayoutConstraint(item: label1, attribute: .top, relatedBy: .equal, toItem: view, attribute: .topMargin, multiplier: 1.0, constant: 0.0).isActive = true
// end of label1