Imagine the case where you have three buttons side by side. You want the three buttons to fill the available width, and be perfect squares with a minimum size set, with a set amount of space between them. To set this up, you would have the following constraints:
A:
1:1 Ratio to A
Leading to superview
Width and height >= 25
B:
Equal width and height to A
Leading to A: 50
C:
Equal width and height to A
Leading to B: 50
Trailing to superview
Now imagine the available width is small enough such that there isn't enough horizontal space in order to ensure the buttons are a perfect square with 50 between each of them. Instead of breaking the aspect ratio and width constraint, you would instead like to decrease the amount of space between the buttons. My question is, how do you do that?
I thought I would just change the relation of the leading constraints to be less than or equal, but this results in Inequality Constraint Ambiguity with those two constraints. I figured perhaps I need to specify a minimum value for leading, so I added two more leading constraints set to be greater than or equal to 10. That didn't resolve the ambiguity. I then added another set of leading constraints, this time equal to a set value that is in-between the two values, then I decreased the priority of those. This resolved the ambiguity, however the space between the buttons is never decreased - it's always the value I set for the constraint with the equals constraint despite its lowered priority.
What constraints need to be set to obtain this?
- Three buttons displayed side by side in the same horizontal space
- All three buttons are perfect squares
- A minimum size for the buttons (25x25)
- A set amount of space between them - 50
- When the horizontal space is too small to ensure the constraints can all be satisfied, it should decrease the amount of space between the buttons.