'Expand UIView width when label inside has more text

I have 2 UIViews with labels inside. The UIView should expand depending on the content in the label. Following is the layout: enter image description here

Both of the above views can expand depending on the content in the label. I have tried to set layout with autolayout but the width is always fixed. Following are my constraints for second view:

enter image description here

First view constraints: enter image description here



Solution 1:[1]

It looks like your first view is missing a leading constraint to the label inside.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CallumOz