0

I have the following View:

enter image description here

How to make so that they all are at the same distance between each other ? Preferably to be done using autolayout (not programmatically), but any answer would be great.

Currently stucked with Tue, Wed, Fri, Sat. Monday has a constraint Leading space to superview. Thursday is centered horizontally and Sunday has Trailing space to superview.

So basically need to position Tue and Wed so that distances between Mon, Tue, Wed, Thu are the same... (and same for Fri and Sat)

Tung Fam
  • 7,899
  • 4
  • 56
  • 63

2 Answers2

1

How to make so that they all are at the same distance between each other ? Preferably to be done using autolayout (not programmatically)

You are describing the problem of _equal distribution.

This is exactly what a stack view is for — but, as you have said, stack views are a recent creation. So what if you need to do this on an earlier system, where there are no stack views? You need to do, in essence, what a stack view does — you insert spacer views. You can easily specify, using constraints, that these spacer views have equal widths to one another, and this, together with your other constraints, will solve the problem.

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

Check out this solution(fully based on autolayout in storyBoard): https://github.com/Petro-Lomaka/equalButtonsWidthAutoLayout

Petro
  • 84
  • 3