ios7nslayoutconstraint

iOS constraints: 4 Buttons


I would like to place 4 buttons on the screen. They should be all of the same height and width. The margin between the buttons should be 35px and the outter margin to the views border should be 20px.

Now the buttons should be scaling to the different sizes of the screen. But all my tries with the constrains have failed.

Does somebody know how to use them properly?

layout:

---------------
|             |
|   x     x   |
|             |
|   x     x   |
|             |
---------------

X are the buttons


Solution

  • If the result you want is the one presented below, please follow the steps:

    enter image description here enter image description here

    Always keep in mind this method. Design your view as-it-should-render in your storyboard (600x600) and then apply your constraints.

    enter image description here

    enter image description here

    enter image description here

    Deselect Constraint to margins before applying constraint.

    enter image description here

    You're all set, your view will now scale appropriately, no matter what's the screen size.