Evenly space multiple views within a container view

后端 未结 29 2918
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 06:14

Auto Layout is making my life difficult. In theory, it was going to be really useful when I switched, but I seem to fight it all of the time.

I\'ve made a demo proje

29条回答
  •  梦如初夏
    2020-11-22 06:26

    I wanted to horizontally align 5 images, so I ended up following Mete's response with a small difference.

    The first image will be centered horizontally in container equal to 0 and a multiplier of 1:5:

    The second image will be centered horizontally in container equal to 0 and a multiplier of 3:5:

    And like that for the rest of the images. For example, the fifth (and last) image will be centered horizontally in container equal to 0 and a multiplier of 9:5:

    As Mete explained, the order goes 1, 3, 5, 7, 9, etc. The positions follow the same logic: the first position is 1, then space, then the next position 3, and so on.

提交回复
热议问题