I've created a horizontal UIStackView with two subviews:
- A
UILabel. - A custom
UIControl.
I would like the Label to expand within the view and for the Control to hug its content.
Content Hugging Priority is set to (in Interface Builder):
- Label: 240, Control: 255
Content Compression Resistance Priority is set to (in Interface Builder):
- Label: 756, Control: 732
As you can see in the screenshot below, the label is being hugged by its bounds and the control is expanding to fill the remaining space, which is the opposite of what I've specified in the size inspector.
What am I missing here?
Other Notes:
- I don't have any other constraints set for Label or Control.
- The StackView's spacing is set to 0 and it has leading and trailing constraints set to its superview.
- If I remove the custom control and just add another label to the StackView, the hugging and resistance properties work as expected.

I was able to solve it by doing the following.
customControl.sizeToFit()followed bysetNeedsLayout()after callingsetupNibView().