Content Hugging vs Compression Resistance [2024-updated] — Simplified

Priorities are very much important when dealing with autolayout. Every constraint has a priority. It is just a number ranges from 0–1000 .

iOS Essentials


According to apple docs: The layout priority is used to indicate to the constraint-based layout system which constraints are more important, allowing the system to make appropriate tradeoffs when satisfying the constraints of the system as a whole.

The priority really come in to play only if two different constraints conflict. The system will give importance to the one with higher priority. So, Priority is the tie-breaker in the autolayout world.

Intrinsic content size (Apple docs)

Content hugging priority:

Sets the priority with which a view resists being made larger than its intrinsic size. Setting a larger value to this priority indicates that we don’t want the view to grow larger than its content.