Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit multiple constraints at once in Xcode's Interface Builder

I have a layout of UIButtons that looks like this:

enter image description here

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:

enter image description here

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.

like image 675
Suragch Avatar asked Oct 12 '15 04:10

Suragch


Video Answer


3 Answers

Just use Command + click to select multi constraits,

like the gif

enter image description here

like image 172
Leo Avatar answered Oct 09 '22 22:10

Leo


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.

like image 37
Sunny Shah Avatar answered Oct 09 '22 23:10

Sunny Shah


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.

enter image description here

like image 22
Jigaroza287 Avatar answered Oct 10 '22 00:10

Jigaroza287