I'm trying to debug an Auto Layout problem, and knowing the default values for Content Hugging and Content Compression Resistance priorities will help.
What are they? Are they specific to particular components? Are there constants I can use to refer to them?
Keywords: UILayoutPriority
These values are up-to-date as of Xcode 7.3.
Interface Builder Default Priority Values:
When dragging a component into Interface Builder, you get the following priorities. Note:
(250,750)
stands for250
horizontal, and750
vertical.Findings:
750,750
as their Content Compression Resistance Priority.250,250
as their Content Hugging Priority.UIImageView
andUILabel
both have251,251
as their Content Hugging Priority.UIActivityIndicatorView
,UIStepper
, andUISwitch
have750,750
as their Content Hugging Priority.UIProgressView
has250,750
as its Content Hugging Priority.Programmatic Default Priority Values:
When creating an object programmatically (e.g.
UIButton()
), you get the following priorities.Findings:
Programmatic Constants
When you add a constraint (either via Interface Builder or programmatically), its default priority is
1000
.