I have a UIView container, that has left/top/right constraints against the super view. So the dimensions are dynamic, except for height. It does not have bottom constraint
This view has content inside (labels and so on). These elements also have constraints against each other and the super view ( to justify em )
Label1
-> Label2.top : Label1.bottom (+left and right of superview)
Label2
-> Label3.top : Label2.bottom (+left and right of superview)
Label3
and so on.
Labels have dynamic size, so, i can't get for sure what is the height of the label. It uses attributed strings. So calculating the subviews rects is not the solution
What i want to achieve is to set proper height of the main container considering constraints I am tired of googling, all i get is some frame rect manual calculations, which dont not work with constraints.
This are the constraints for elements inside:
self.view.addConstraint(NSLayoutConstraint(
item:self.view, attribute:.Trailing,
relatedBy:.Equal, toItem:label,
attribute:.Trailing, multiplier:1, constant:0))
// left
self.view.addConstraint(NSLayoutConstraint(
item: label, attribute:.Leading,
relatedBy:.Equal, toItem:self.view,
attribute:.Leading, multiplier:1, constant:0))
// Top
self.view.addConstraint(NSLayoutConstraint(
item:parentView, attribute: positionConstraint,
relatedBy:.Equal, toItem:label,
attribute:.Top, multiplier:1, constant:0))
Help me please!