I have a layout of UIButtons that looks like this:
The horizontal spacing between the buttons is 8. I would like to change this to 4. Of course, I could change them one by one, like this:
But there are a lot of buttons and I don't really feel like doing that.
I tried selecting multiple buttons and then added a horizontal space constraint of 4 but that just adds constraints. It doesn't update the old constraints. This creates conflicting constraints with the old ones.
I didn't see anything to solve this in the Editing Auto Layout Constraints documentation.
Just use Command + click to select multi constraits,
like the gif
One of the way is to create spacer views, With each view width equal to the first one. Set your Button constraint to leading and traling to the spacer view. and if you change first width of spacer view it will change all othes view width.
I am agree with the answer of @Leo and up voted as well :)
Just adding to it, if someone would like to make it more easier, he can use the filter option given below the constraints.
For example to find all the leading constraints one can search for " = leading" word or "trailing = " for trailing constraints or other similar search string.
You can see this from the GIF as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With