Content hugging vs compression resistance?
The gist
These are two priorities that Auto Layout attaches to the intrinsic content size along each axis:
- Content hugging — resistance to being stretched beyond the intrinsic size. High priority: "don't stretch me, hug the content". Default 250 (a
UILabelin Interface Builder gets 251). - Compression resistance — resistance to being compressed below the intrinsic size. High priority: "don't clip my content". Default 750.
Both are optional constraints (< 1000), so when space runs out the system "breaks" the one with the lower priority. Hugging matters when there is more space than needed; compression resistance when there is less.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep