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
5
votes
2 answers

How to create StackView with width = largest child's width on iOS?

I want to place label to the bottom of image and align them vertically. I've tried to use StackView to achieve this. And I get this: Is there any way to show all label's text correctly? Label text can have any length.
Semyon Tikhonenko
  • 3,872
  • 6
  • 36
  • 61
5
votes
1 answer

Should I enclose "addArrangedSubview" to the animation block or not?

I'm not learning the use of UIStackView and read a good tutorial on the web. In the tutorial, the author writes the following code to make an animation: @IBAction func addStar(sender: AnyObject) { let starImgVw:UIImageView = UIImageView(image:…
Blaszard
  • 30,954
  • 51
  • 153
  • 233
5
votes
1 answer

UIStackView and multi-line labels in a UITableViewCell

I want to have a custom UITableViewCell with a number of vertically stacked UILabels all of which can contain text that wraps multiple lines. With the new UIStackView in iOS9 and the cell self-sizing mechanism I thought this would be…
AndrewC
  • 401
  • 4
  • 19
4
votes
1 answer

Change default StackView animation

Forgive me if explanation is not excellent. Basically, the video below shows the standard animation for hiding labels in a stack view. Notice it looks like the labels "slide" and "collapse together". I still want to hide the labels, but want an…
JEL
  • 1,540
  • 4
  • 23
  • 51
4
votes
2 answers

Why does a UIStackView with a single view, fill Proportionally, and Layout Margins causes ambiguous constraint error?

The following code is an attempt to add a UIStackView to a view controller, pinned on all edges with a little margin, and add a label to it. I want the StackView to use .fillProportionally as its distribution mode ready for when I add more views…
user1636130
  • 1,615
  • 5
  • 29
  • 47
4
votes
2 answers

UITextField is not filing available width inside UIStackView

I want to put two buttons with images on left and right edges of the screen, and insert a UITextField between them. In storyboard everything is fine, but I need to do it programmatically. Source: class SecondViewController: UIViewController…
FezZ
  • 73
  • 1
  • 8
4
votes
1 answer

Hide arrangedSubviews in UIStackView instead of clipping contents

I have a UIStackView with three labels whose height is determined using Dynamic Type and text that have can wildly varying lengths. The container for the stack view has a fixed width and height depending on device screen size (small on iPhone SE,…
chockenberry
  • 7,811
  • 5
  • 32
  • 41
4
votes
2 answers

How to set the scrollview height when UI elements are dynamically created

On the storyboard, inside a view controller I have a scrollview. A navigation bar and a stack view are embedded inside the scrollview. Programmatically I am adding some UI elements one below the other inside the stack view. Via storyboard,…
learner
  • 139
  • 1
  • 13
4
votes
2 answers

Prevent vertical UIStackView from stretching a subview?

I have a UITableViewCell with a vertical UIStackView that currently has .alignment = fill and distribution = fill. Inside the stack view, I have a UILabel and a UIImageView. The label should be left aligned and stretch across the width of the…
bmt22033
  • 6,880
  • 14
  • 69
  • 98
4
votes
1 answer

UITableViewCell doesn't change height when some UIStackView's subviews are unhidded

As the title says, I have a custom UITableCell in which I have some UIStackViews. Each of those stacks contains many subviews but I just want to show three of them when the cell is displayed for the first time. If a user wants to see more, there is…
Pere Rumbo
  • 95
  • 1
  • 8
4
votes
2 answers

UIView dynamic height inside UIStackView

I currently have a Stack View setup with a bunch of different objects inside of it, and I'm trying to add a view to it. The view will have a dynamic number of labels added inside of it programmatically at run-time. When I put the view inside of the…
Logan
  • 1,172
  • 9
  • 23
4
votes
3 answers

How to give dynamic height to labels contained withing stackview in swift

Inside a UItableview Cell I have following structure. It has two Stackviews Left and Right 1) Left Stackview contains 3 views. Each view containing 1 label (Label1,Label2,Label3) 2) Right Stackview contains 2 views. Each view containing 1 label…
user7420795
  • 199
  • 1
  • 15
4
votes
2 answers

Replace view inside UIStackView?

I have UIStackView which contains 3 subviews. And it is created via storyboard. What if I need in some cases replace the middle subview with another one? What is the best way to solve this issue without of recreating the whole stack view…
Vyachaslav Gerchicov
  • 2,317
  • 3
  • 23
  • 49
4
votes
1 answer

Problems when embed an UIStackView in an UIScrollView

I'm setting up an iOS app interface from the Interface Builder. I've several horizontal stack views, all embedded in a single vertical stackview. Up to here, the layout seems to be ok and the constraints are well done. When I embed the vertical…
pairon
  • 427
  • 1
  • 7
  • 18
4
votes
5 answers

UIStackView Hiding/UnHiding arrangedSubView issue

I am hiding and unhiding dropDownView(UIView consisting of textfield and button) based on Segment tapped in Segment Control. Following is the view hierarchy :- Following is the code which hides/unhides dropDownView :- private func…
Meet
  • 1,196
  • 12
  • 26