Set UIView size to fit subViews
You can do it using the storyboard itself.
Set the View's bottom constraint to second UIlabel. So when the height of label increases, UIView's height will also increases.
@Girish M answer is correct. Just to clarify. Set the top label's constraint to the views' top, vertical spacing between the two labels and a bottom constraint between the bottom label and UIView. Do not set any height constraints.
Alternatively, if you want a bit more control over the heights of the UILabels, you can add height constraints in storyboard for the labels and create outlets for them in your code. Perform this code when changing the text of the labels.
label1.sizeToFit()
label2.sizeToFit()
label1HeightConstraint.constant = label1.frame.size.height
label2HeightConstraint.constant = label2.frame.size.height
view.layoutSubviews()