Questions tagged [uistackview]

The UIStackView class provides a streamlined interface for laying out a collection of views in either a column or a row. Stack views let you leverage the power of Auto Layout, creating user interfaces that can dynamically adapt to the device’s orientation, screen size, and any changes in the available space.

The UIStackView class provides a streamlined interface for laying out a collection of views in either a column or a row. Stack views let you leverage the power of Auto Layout, creating user interfaces that can dynamically adapt to the device’s orientation, screen size, and any changes in the available space. The stack view manages the layout of all the views in its arrangedSubviews property. These views are arranged along the stack view’s axis, based on their order in the arrangedSubviews array. The exact layout varies depending on the stack view’s axis, distribution, alignment, spacing, and other properties.

enter image description here

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. Next, drag out the stack’s content, dropping the view or control into the stack. You can continue to add views and controls to your stack, as needed. Interface Builder resizes the stack based on its content. You can also adjust the appearance of the stack’s content by modifying the Stack View’s properties in the Attributes inspector.

1429 questions
9
votes
2 answers

How can I delete stack view from storyboard

I'm trying to make my UI design by stack view. Unfortunately, I'm unable, so now I want to delete stackview from my storyboard. I have no idea how to delete it and go restore my previous design without stackview. So how do I do this ? I already…
user5978134
9
votes
2 answers

Is there a way to keep subviews of a UIStackView participating in autolayout when they're hidden?

I introduced some UIStackView's in my latest project, because it made the spacing of the views and adding other autolayout constraints a lot easier. Only to discover that hidden views inside a UIStackView no longer 'participate' when autolayout does…
Pieter
  • 17,435
  • 8
  • 50
  • 89
9
votes
1 answer

Specifying z-order (sendSubviewToBack, etc.) on UIStackView

According to the Apple docs: The order of the subviews array defines the Z-order of the subviews. If the views overlap, subviews with a lower index appear behind subviews with a higher index. I can see that this is the case, as I am trying to have…
Connor Neville
  • 7,291
  • 4
  • 28
  • 44
9
votes
3 answers

UIStackView with UILabels in Xcode 7.3

Since I've updated to Xcode 7.3 I have a problem with UIStackView. If I create an empty project and just put two UILabels in UIStackView with default hugging and compression priorities, it shows me AutoLayout misplacement error. It even doesn't work…
Evgeny
  • 631
  • 6
  • 17
9
votes
3 answers

Finding the size of a view adjusted by a UIStackView swift

A number of views in a UIStackView are adjusted to fit the stack. The views are initialised with no frame because they are resized by the stack view. Is there a way which I can get the size of the views after they have been resized by the stack…
Matt Spoon
  • 2,760
  • 5
  • 25
  • 41
8
votes
1 answer

Get View's index from UIStackView

I have added 2 views in stackview with different size. Now When I click on plus button of any view, I just wanted to add a view right below that. I am getting view by: let index = superView.subviews.index(of: view) and then I am…
PJR
  • 13,052
  • 13
  • 64
  • 104
8
votes
1 answer

Left aligned horizontal stackview and top aligned vertical stackview

I have two StackView, one of which is horizontal and another vertical. For the horizontal StackView, I want the items to be aligned to the left and grow toward the right. For the vertical StackView, I want the items to be aligned to the top and grow…
Brejuro
  • 3,421
  • 8
  • 34
  • 61
8
votes
2 answers

UIStackView: push subviews to the edges ("Unlimited" spacing)

I am using UIStackView to define a list's layout. I am trying to achieve the effect similar to this: ||Item1---spacing---Item2|| So, the two items are being pushed to the sides of the UIStackView. However, the items are grouped together in every…
Richard Topchii
  • 7,075
  • 8
  • 48
  • 115
8
votes
2 answers

iOS horizontal UIStackView with 3 labels - First label pushed other labels out of sight

I'm not sure if I understand UIStackView correctly. I have a UIStackView in a UITableViewCell. It contains 3 UILabel and is set to align and distribute Fill. When my first labels text is not very long, it looks all good. The second and third label…
xxtesaxx
  • 6,175
  • 2
  • 31
  • 50
8
votes
2 answers

Programmatically Set Spacing on Stackview

Like the title says, I have searched around but had no luck. Is it possible to connect the stack view to the .swift file and then adjust the spacing programmatically? Thank you!
SF Dev
  • 389
  • 1
  • 3
  • 13
8
votes
2 answers

UIStackView without distribution or filling

I have a view on my app where I need to be able to push a dynamic number of custom subviews (the number of views changes whilst its running). My original idea was a tableview, but it seems a bit OTT setting up all the delegate methods. Then i found…
TRG
  • 845
  • 1
  • 9
  • 22
8
votes
2 answers

Unable to get stack view to fill it's super view

I am unable to get a stack view to fill the view canvas in order for my widgets to be automatically resized to fill the entire screen... i've seen this done on may tutorial/youtube video but for some strange reason it doesn't seem to work for…
user2094257
  • 1,645
  • 4
  • 26
  • 53
8
votes
1 answer

Override spacing for a UIStackView

I frequently find that a UIStackView is perfect for a particular layout, except that I need some variable spacing between the arranged subviews. UIStackView uses its spacing property to arrange the views along its axis, but is there a way to…
Ben Packard
  • 26,102
  • 25
  • 102
  • 183
8
votes
2 answers

Undoing stack view from storyboard

Xcode 7's interface builder allows stackview to be easily created around subviews via the click of the "Stack" button. However, there seems no way to "unstack" the subviews from a stackview. Is there a way to do this in interface builder?
Boon
  • 40,656
  • 60
  • 209
  • 315
8
votes
1 answer

How to resize subviews of UIStackView in Xcode?

Every time I try to add something to a UIStackView in iOS it autosizes my subviews into something that is too small, so the text is being cut off. How exactly is this StackView supposed to be used? All the guides said it was easy, just drag your…
Jim Moody
  • 758
  • 2
  • 6
  • 18