0

I am trying to create an interface where two labels share a space, similar to an html table with two columns would: there is a distance between the two and when the window is resized they both resize and stay the same size, keeping the distance between them and filling up the available space.

e.g. | 10px to edge | label1 (50%) | 5px spacing | label2 (50%) | 10px to edge |

If the window is resized the margins and the spacing should stay the same while the two labels should evenly distribute the available space between themselves.

After multiple attempts (e.g. putting them in a custom view takes care of the margins) I cannot figure out the correct layout constraints to make this happen.

Samuel
  • 18,286
  • 18
  • 52
  • 88

1 Answers1

1

I had the same problem until I read your problem. Because I read your problem, I gave myself another try:

You can resolve it by going into the storyboard. Then, you select both labels. After that, you add the following constraints:

enter image description here

Now the labels resize correctly. The trick here is to edit the constraints of both labels together. Otherwise the Equal Widths choice isn't available.

Christian
  • 22,585
  • 9
  • 80
  • 106