title: How do I make elements a percentage width in Xcode
body: <p>I am new to <code>Xcode</code>, previously developed apps as hybrid so decided to learn <code>swift</code>. The language itself is easy to learn, I code in many languages. But I am not understanding why <code>Xcode</code> doesn't let me use percentage widths on things!</p>
  
  <p>The first screenshot shows 4 buttons next to each other on <code>iPhone 8 plus</code>, but the second screenshot is when I change to <code>iPad</code>, you can see that the boxes don't resize to fit.</p>
  
  <p>It doesn't allow me to enter percentage (<code>25%</code>) of the view so how am I supposed to make them all fit on difference devices? I know about constraints but I can't figure out what constrains it needs to a) Make them all stay <code>25%</code> of the view b) So they sit next to each other and just resize.</p>
  
  <p><a href="https://i.stack.imgur.com/ZsEmN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZsEmN.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/aSC4c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aSC4c.png" alt="enter image description here"></a></p>
  
  <p>After trying the accepted answer it worked, but when I try to add a second row doing the same thing the following happens:</p>
  
  <p><strong>Setting constraints for first row:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/71wsc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/71wsc.png" alt="enter image description here"></a></p>
  
  <p><strong>Setting constraints for second row:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/l1jIM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l1jIM.png" alt="enter image description here"></a></p>
  
  <p><strong>The result:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/I4tBH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I4tBH.png" alt="enter image description here"></a></p>
  
  <p>Why did it work for the first row but not the second?</p>