0

I'm trying to build an app that has just a single portrait oriented view. There is a title on top and results label at the bottom of the view, these are locked to top and bottom and center, no problem here.

Now this is the tricky part. I have 9 rows of labels, most single row but couple span out to 2 rows. I want them to spread out evenly between the title and the result-label.

I lock the first label to top-left, lock the leading edges and then set equal vertical distance constraints between the labels. Otherwise ok but the last labels on 3.5 inch display overrun my results -label.

So I adjust either the fontsize or make vertical distance between labels smaller or both. 3.5 inch problem fixed but now there is a big empty gap between the last label and result. On iPhone 6 its really ugly.

I have tried all sorts of methods but can't just get this working.

So basically: how do I reserve 10 % of view height from top and 20 % from bottom and tell Xcode to use the rest 70 % (and all of it) for my 9 rows of label, evenly?

Thanks for help!

Would have posted an image but no rank for such things...

Timo Strid
  • 101
  • 3
  • 9

1 Answers1

0

If I understand you right, you need several flexible spaces that will all be the same size. One space in-between each of the labels.

Create UIViews to put between each label, set them all to have equal widths or heights and anchor each one to the views it is supposed to sit between.

I got this idea from another SO question: Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5

Community
  • 1
  • 1
Daniel T.
  • 32,821
  • 6
  • 50
  • 72
  • I found the same advice but wasn't able to make it work, possibly because I was trying to fill the empty spaces with labels. The UIView work so much more better. Thank you! – Timo Strid Nov 04 '14 at 22:54