Content hugging and content Compression resistance
These two properties are important for controls that have intrinsic content size (for example, Button,label). In layman's terms, a control with intrinsic content size knows (can calculate) its own size, such as a label, and when you set Text,font, its size can be calculated. About the intrinsic content size official explanation:
Hugging priority determines how large the view has to prevent itself from getting bigger.
Compression resistance priority determines how much precedence prevents you from getting smaller.
Hugging priority determines how large the view has to prevent itself from getting bigger.
Compression resistance priority determines how much precedence prevents you from getting smaller.
Very abstract, in fact content hugging is to maintain the current view in its optimal size (intrinsic content size), you can imagine to add an extra width to view constraint , this constraint tries to keep the size of the view from getting bigger :
View.width <= Optimal size
The priority of this constraint is obtained and set by the method above, and content hugging defaults to 250.
Content Compression Resistance is to maintain the current view in his optimal size (intrinsic Content size), which can be imagined as adding an extra width to the view Constraint, this constraint tries to keep the size of the view from getting smaller :
View.width >= Optimal size
This default priority is 750.
Content hugging and content Compression for IOS AutoLayout resistance