Reputation: 1619
In my storyboard, I have two buttons at the bottom of the view. Neither of them are in the middle. When I run the program on devices like the iPhone 5s, the first button is aligned to the left where I'd like some space between them. I've tried using a leading and trailing space constraint for the first and second buttons respectively (the two have a trailing/leading constraint between each other), but this then causes the buttons to go off-screen. This is how the view looks on the storyboard, which is what I'd like it to look like:
How do I make sure that both buttons stay on the screen w/ proportional distances between each other and to the sides of the screen?
Upvotes: 0
Views: 72
Reputation: 3681
After you have added bottom constraints to your buttons select them both and set X centered in container:
After that, select each button individually and in Size Inspector find this "align X center" constraints and set offset by changing the constant. Say you want them to be 100 points apart. Set constant 50 pts for one of them and -50 pts for the second one.
This is how it's going to look:
And that's it! Only 2 constraints for each button needed. Here's how it will look on the device:
Upvotes: 1