title: Autolayout design accommodating iPhone 3.5 inch and iPhone 4 inch screen size
body: <p>I'm creating an universal app. Now I want to place two buttons on the screen:</p>
  
  <p><img src="https://i.stack.imgur.com/6IyLp.png" alt="Placement of two buttons"></p>
  
  <p>I tried it with autolayout and Interface Builder (iOS Designer exactly) but I only managed to fit the buttons on one screen size (e.g. 3.5 inch display). Therefore I set the size of the buttons and the spacing to the top (one to the top of the superview and one to the bottom of the button above).</p>
  
  <p>But is there a way to adapt this to the screen size? E.g. the width of the button is the the view width minus a certain gap. Or centering the buttons like in the picture (one would be easy)? Is this possible?</p>
  
  <p>Than the other option is to do everything in code (creating the button and creating the constraints). Here I could query the view width and so on to create my buttons accordingly. Is this the only way?</p>
  
  <p>How can this be managed?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Now I placed an empty label on the view controller. On this label I added the following constrains:</p>
  
  <ul>
  <li>Align Center Y to: Superview, Equals: 0</li>
  <li>Align Center X to: Superview, Equals: 0</li>
  </ul>
  
  <p>On my buttons I set a fixed height and width. Than the trailing space to the superview equals 50 (horizontal centering works because both screen sizes have the same width). The button on top has the following constraint:</p>
  
  <ul>
  <li>Align Center Y to: Label, Equals: 20</li>
  </ul>
  
  <p>The button on the bottom gets:</p>
  
  <ul>
  <li>Top Space to: Label, Equals: 20</li>
  </ul>
  
  <p>Don't know why it takes different constraints but in the GUI editor I took the bottom or top point of the button. Here the label gets also:</p>
  
  <ul>
  <li>Align Center Y to: top Button, Equals: 20</li>
  <li>Top Space to: bottom Button, Equals: 20</li>
  </ul>
  
  <p>Now I have the two buttons centerd on the screen regardless of 3.5 or 4 inch display. One disadvantage is that the gap to the navigation controller and toolbar is very small on the 3.5inch display. Here I can make the buttons smaller. Any other options? The initial idea was to set always the space to the top element but on the 4 inch screen there is much space on the bottom than.</p>