Search Your Question

What is StackView? What is advantage and distribution type of stackview?

Ans : Stack View allows to layout views in a stack in either horizontal or vertical fashion. In Xcode-7, stackview is introduced.

Advantage : Stacks are containers that keep views aligned automatically.

Distribution Types :

Fill(Default) : When you place your controls inside a UIStackView with Fill set as the distribution, it will keep all but one of the controls at their natural size and stretch one of them to fill the space. It determines which control to stretch by noting which one has the lowest Content Hugging Priority (CHP).

Fill Equally : With this type, each control in a UIStackView will be of equal size. All of the space between the controls will be used up, if possible. I added a spacing of eight between the UITextFields, so again you could see the size of each one. With this type, the CHP does not matter, because each control is the same size.

Fill Proportionally : The UIStackView will ensure the controls maintain the same proportion relative to one another as your layout grows and shrinks. Unlike the previous two settings, the Fill Proportionally distribution needs the controls to have an intrinsic content size. The Fill and Fill Equally distribution tell their child controls how big they should be, but this one is the other way around (as long as there is enough space for all of your controls to be their natural size). The proportions for the images and labels are maintained for the different layout sizes.

Equal Spacing : This distribution type will maintain an equal spacing between each of the controls and will not resize the controls themselves.

Equal Centring :  It will equally space the centres of the controls. Space between every control is equal.


No comments:

Post a Comment

Thanks