fill. A layout where the stack view resizes its arranged views so that they fill the available space perpendicular to the stack view's axis. The simplest of the alignments, . fill constrains the leading/trailing edges of each arranged subview to the leading/trailing edge of the stack view.
Select the top-level stack view and in the Attributes inspector, click the + button next to Spacing: Choose Any Width and Compact Height, then select Add Variation. Set the Spacing to 10 in the new hC field: Build and run.
The exact layout varies depending on the stack view's axis , distribution , alignment , spacing , and other properties. To use a stack view, open the Storyboard you wish to edit. Drag either a Horizontal Stack View or a Vertical Stack View out from the Object library, and position the stack view where desired.
Best use of stack view is that if you want to set multiple controls allinged vertically or horizontally to each other you just add all of them in stack view. stackview will handle its allignment you just need to give frame contraints to stackView.
It's an answer based on Lumialxk's reply. Choose the stack view you want to work on, and change the spacing property to your desired value.
stackView.setCustomSpacing(32.0, after: headerLabel)
For more info: Stack View Custom Spacing
Inside your horizontal stack view have three more horizontal stack views so that you can have control over spacing and distribution for each item. See screenshot below:
Programmatically for each view:
stackView.spacing = 10.0
If you want to make a custom spacing after each view and you need to support lower than iOS11:
Create a clear UIView with height and add it as an addArrangedSubview
into the stackView.
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