Coming from Android development I'm trying to imitate some of the layouts that I've made in past applications, but now on the iPhone and iPad. Something that I use quite often in Android is layout weight. I've done a ton of searching, reading books, blogs, and I thought something like this would be possible in iOS 6, but I haven't been able to find anything. I've also tried watching a ton of tutorials on auto layout in iOS, but I really haven't found anything that accomplishes my task. This is driving me nuts. So... is there an iOS equivalent to Android layout weights?
Layout WeightA larger weight value allows it to expand to fill any remaining space in the parent view. Child views can specify a weight value, and then any remaining space in the view group is assigned to children in the proportion of their declared weight. Default weight is zero.
Per documentation, android:weightSum defines the maximum weight sum, and is calculated as the sum of the layout_weight of all the children if not specified explicitly.
Modify the default content of res/layout/activity_main. xml file to include few buttons in linear layout. Run the application to launch Android emulator and verify the result of the changes done in the application.
The orientation attribute is used to arrange its children either in horizontal or vertical order. The valid values for this attribute are horizontal and vertical. If the value of the android:orientation attribute is set to vertical, the children in the linear layout are arranged in a column layout, one below the other.
Use StackView (similar to LinearLayout in Android)
Select Distribution = Fill Equality (similar to weight)
Example:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With