Label width resizes in a stack view

I have a hotizontal stack view with labels in it.
While creating the labels, I set the widthAnchor to the calculated width based on the text that goes in the label.

let labelSize = tagsArray[i].rectWithConstrainedWidth(view.frame.width, font: Theme.Font.medium(size: 17.0).font())
label.widthAnchor.constraint(equalToConstant: labelSize.width).isActive = true

However, the stack view resizes it to the full width of the screen.
How do I maintain the label width in the stack view?

Terms of Service

Privacy Policy

Cookie Policy