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
13
votes
3 answers

How can I disable horizontal scrolling and page will change on click in paging using UIScrollView?

I have a UIScrollView with pagingEnabled. Added 5 UIStackView to subview of UIScrollView and also had one UISegmentedControl. I want to show currently selected segment and also want to disable horizontal scrolling but the view will able to scroll…
13
votes
3 answers

Swift UIStackView utilize full width of UIStackView

In above screen, you can see I am using a UIStackView to fill radio buttons vertically. problem is my radio buttons not utilising the full width of UIStackView when I use stackV.alignment = .leading it shows label as "dis..lified" instead of…
Deepak
  • 1,030
  • 2
  • 10
  • 21
13
votes
2 answers

UIStackView won't animate when changing the hidden property on iOS 9

I am using a Stack view to create a kind of table UI, I have 6 views in a StackView 0,2,4 are visible and 1,3,5 are hidden. When tapping one of the visible views I wish to "open" one of the views that are hidden. I have this code that works great on…
shannoga
  • 19,649
  • 20
  • 104
  • 169
13
votes
2 answers

how to programmatically reorder items within a UIStackView in IOS?

How can one programmatically reorder items within a UIStackView in IOS? (i.e. I can not see a function at https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStackView_Class_Reference/#//apple_ref/doc/uid/TP40015256-CH1-SW30 to…
Greg
  • 34,042
  • 79
  • 253
  • 454
13
votes
2 answers

addArrangedSubview without animations

I add views to a TZStackView (which should be basically the same as a UIStackView, but with a fallback for older versions) like this: stackView.addArrangedSubview(subview) the stackView and the subview are of dynamic size (auto-layout) and resize…
Daniel
  • 20,420
  • 10
  • 92
  • 149
13
votes
2 answers

Animating UIStackView arrangedSubview content size change

Is it possible to animate an arranged subview when its intrinsic content size changes? For example, imagine I have an arranged subview, which holds a single UILabel pinned to edges. That label has a small amount of text. New text comes in, which is…
13
votes
2 answers

Adding UIStackView as a empty container in Storyboard

My wish is to have a UIStackView added in the Storyboard with 0 height that I reference in the code to add subviews to programatically. However, Storyboard is complaining about that it doesn't have a height (I haven't set it, so it is correct that…
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
13
votes
3 answers

UIStackView and truncated Multiline UILabels

I want to add several multiline Labels to an UIStackView. But I always end up my Labels being truncated. As seen in this Screenshot But I like to have it more as shown here (my faked Screenshot) Here is my Code. First I create the parent/master…
Flori
  • 2,453
  • 1
  • 21
  • 31
13
votes
2 answers

Constraints to center and object between two objects

My design requires that a button is centered between two other objects. One of the objects is in the vertical center of the view (green). The other object is some distance from the bottom edge (green). Now the task is to center the third object…
Joe Andolina
  • 648
  • 1
  • 11
  • 23
12
votes
1 answer

addArrangedSubview vs addSubview

I'm newbie and I've wrote a customView inherited from StackView and I created a button programmatically with few attributes and when I add it to my custom view, I have two problems: If I use addArrangedSubview(myBtn), my view ignores attributes…
Mahdi Moqadasi
  • 2,029
  • 4
  • 26
  • 52
12
votes
1 answer

Shadow is not showing for UIStackView

I am trying to give shadow to a UIStackView. My stackview is in a prototypecell having some labels and buttons. Firstly, I have made a reference of stackview with name UIViewBank in a class that is binded to my custom cell: class CustChatBankCell:…
Share Knowledge
  • 121
  • 1
  • 7
12
votes
1 answer

How to Add Constraint for view inside stack view

I have one stack view that contains with 4 buttons. And each button I also add subview to that. The subview of that 4 buttons, I try to program to add constraint into it. Some constraint such as .Trailing .Leading .Top .Bottom I cannot add to it by…
Leang Socheat
  • 1,156
  • 2
  • 12
  • 23
12
votes
0 answers

StackView with a MapView not working properly on initial load

Quick update, as I see a lot of interest in this now that iOS 10 is live. I ultimately opened a TSI and Apple responded back today indicating that I should open a bug for this. They didn't provide any further info or suggestions for workarounds, and…
jeffro37
  • 696
  • 6
  • 16
12
votes
1 answer

How do I get a UIStackView to update its layout?

I have a UIStackView with 5 subviews. I want to be able to animate the width of these subviews by updating their intrinsicContentSize or updating their constraints. How can I make the stackView redraw after updating the subview's layout? …
James P
  • 4,786
  • 2
  • 35
  • 52
12
votes
1 answer

Bad performance of UIStackView within UICollectionViewCells

I am using UIStackView to layout UILabels in my UICollectionViewCell subclass. I'm using the iOS SDK 9.2 The scrolling of the collection view is smooth if I don't update the labels' text when I dequeue them. However, if I update their text as I…
Eric
  • 16,003
  • 15
  • 87
  • 139