Constraining stackviews

·

0 min read

This SO article was helpful for me: stackoverflow.com/questions/56138193/constr..

However I couldn't figure out the difference between which attribute to use and the relatedBy.

With normal constraints I got the result I wanted. But I couldn't define the correct NSLayoutConstraintAttribute.

let topConstraint = NSLayoutConstraint(item: bottomLabel,
                                               attribute: .top,
                                               relatedBy: .equal,
                                               toItem: topLabel,
                                               attribute: .bottom,
                                               multiplier: 1,
                                               constant: 0)
myStackView.addConstraint(topConstraint)