I am puzzled with a simple layout created programmatically, where you have a UILabel
, a UITextField
and a UIButton
in a row using constraints. I hope you can help me understand the following behaviour.
If I use visual format language to lay out those views like this...
|-[label]-[field]-[button]-|
...I see that the label wants to take as much space as possible, like this:
[ label ] [field] [button]
But if I remove the label from the equation...
|-[field]-[button]-|
...then it's the button who wants to take over the space:
[field] [ button ]
By setting a "high hugging priority" to the label and button I can control their size (they keep their intrinsic size, I guess). But I don't know why the differences in behaviour in these cases.
Do you know how is autolayout exactly working here?
Related question:
Using Auto Layout to have UILabel and UITextField next to each other