Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to adjust space between buttons equally using AutoLayout

I have a main screen with three button vertically aligned. I want adopt my app for 4" screen. so I want to adjust space between buttons equally to fill the screen. see the below images: how can I accomplish that using AutoLayout?

the green area keeps its size.

enter image description here enter image description here

like image 552
Hashem Aboonajmi Avatar asked Dec 29 '25 23:12

Hashem Aboonajmi


1 Answers

Edit: Apple now favors the use of stack views for this purpose. See this WWDC 2013 video for OS X and this iOS one from WWDC 2015

The Apple approved way of doing this (look for section titled "Creating Equal Spacing Between Views") is to insert hidden views between each of your buttons and set those views' heights to be equal.

See my answer over here for some discussion on why this approach makes sense.

like image 89
jemmons Avatar answered Jan 02 '26 05:01

jemmons



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!