Reputation: 16526
I'm having issues programmatically changing constant for a height constraint. Debugging my layout I've figured out that somehow there's a height constraint automatically being created, I'm guessing this constraint is causing the issue.
How can I get rid of those (content size)
constraints?
Upvotes: 0
Views: 31
Reputation: 11123
Those content size constraints in the view debugger are there to represent the intrinsic content size of the view, and are perhaps a little misleading. The intrinsic content size can act as a required constraint, but only does so if you set the content hugging and compression resistance of your view to have a required priority. Clicking on those constraints in the view debugger seems to always show them with a required priority (i.e., 1000) even when that is not necessarily the case.
Having said that, you can adjust the relative priority of these content size constraints in Interface Builder using the Size Inspector.
You can also adjust them programmatically with the setContentCompressionResistancePriority(_:forAxis:)
and setContentHuggingPriority(_:forAxis:)
methods of your UIView
instance.
You can read more in the Views with Intrinsic Content Size chapter of the Auto Layout Guide.
Upvotes: 1