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
3
votes
1 answer

How can a stackview dynamically change the spacing between the elements nested inside of it

For months now I have been trying to wrap my head around stackviews and how they work. For that reason I have created a project which has 4 buttons nested inside of a stack view with constant width and height. Now depending on the iPhone screen…
Defkalion1
  • 77
  • 1
  • 12
3
votes
1 answer

UIStackView with multiline label in a UITableViewCell incorrect height

I have a table view where each cell displays an optional title and a multiline subtitle. I want the cell to be self-sizing (i.e grow along with the subtitle but stay as compact as possible). For that I use tableView.rowHeight =…
Jan
  • 7,444
  • 9
  • 50
  • 74
3
votes
1 answer

UITableViewCell height not dynamic when constrained to UIStackview containing multi-line UILabels

I have a tableview cell that contains a UIStackView. The stack view contains two labels that could be multiple lines and another stackview at the bottom. This is how the cell should appear, but with more margin. This has a 15 point constraint on the…
yamski
  • 471
  • 4
  • 14
3
votes
2 answers

Width of button in horizontal stackview - iOS - Storyboard

I have two controls in vertical stack views and below is my problem I want my controls to display like this Instead it displays like this How can I set my button title fit so that the button's width do not increase Also the button title is dynamic…
Ashh
  • 569
  • 1
  • 6
  • 28
3
votes
1 answer

Choose which subview on a stackView will stretch (Programmatically)

I have a display of horizontal stack views, which subviews consists on a label and a textField. the stackView is constrained with the borders of the view I'm trying to stretch my textField subview to so it fills the remaining space of the stack,…
3
votes
0 answers

UICollectionView didSelect not called in a specific view hierarchy

I'm hurt to an edge case I guess? Here is my current view hierarchy of the my problematic top most view controller. UIView-> UIScrollView-> UIView-> UIStackView-> UICollectionView My stack view contain multiple arranged views. What happen is that…
Dimillian
  • 3,616
  • 4
  • 33
  • 53
3
votes
1 answer

Layout issue with the Xcode

Swift layout issue. I want to set my stackView at the bottom part. I set the proper constrain even my stackView not fix at the correct place. Here is the attach image. Here is my Constrain Setup. Can you please explain what is the actual…
Krunal Nagvadia
  • 1,083
  • 2
  • 12
  • 33
3
votes
2 answers

How to shrink font size to fit in the stackview but remain the same fontsizes in the whole stackview?a

How can I shrink the font size to fit in a stackview of 3 items? It's important to note that the font-sizes should be the same across all views in the Stackview. Please have a look at the issue below. The My Orders tab has a smaller font than the…
Kevin Vugts
  • 1,462
  • 4
  • 21
  • 39
3
votes
1 answer

Custom view with intrinsic content size in uistackview

A custom view with overridden intrinsicContentSize property is added to a UIStackView override var intrinsicContentSize: CGSize { return CGSize(width: 100, height: 44) } Although the custom view is drawn successfully in the simulator, I…
Myrick Chow
  • 332
  • 1
  • 6
  • 16
3
votes
1 answer

UIStackView layer property

Every view has a layer that does the rendering. What confuses me is that you can't set the corner radius or border to the stack view, yet when you hide one of the arranged subviews the rest of them fill up the stack view. Furthermore, Apple doc says…
Rango
  • 229
  • 1
  • 4
  • 14
3
votes
2 answers

UIImageView squished inside UITableViewCell when using UIStackView

I'm seeing some odd behavior when using UIImageView inside a UIStackView and I suspect there's something obvious that I'm overlooking - though I've tried quite a few things at this point. What I'm trying to do is very straightforward: download an…
JaredH
  • 2,338
  • 1
  • 30
  • 40
3
votes
1 answer

Breaking constraints when changing stackview axis

I'm currently trying to change the axis on a stack view based on the orientation of the device. Everything works fine while the phone is vertical, but as soon as I go horizontal my constraints break. Currently, I have the blue view and the orange…
WBuck
  • 5,162
  • 2
  • 25
  • 36
3
votes
3 answers

Stack view - but with "proportional" gaps

Imagine a stack view with four items, filling something. (Say, filling the screen). Notice there are three gaps, ABC. (Note - the yellow blocks are always some fixed height each.) (Only the gaps change, depending on the overall height available to…
Fattie
  • 27,874
  • 70
  • 431
  • 719
3
votes
1 answer

Unable to simultaneously satisfy constraints when update height constraints of imageView swift 4

I have a stack view that look like the figure below: So I change the height of the image programmatically to make it fit the image that download from my server,if dont have image,the height constraints of image will set to be zero. Here is my code…
ken
  • 2,426
  • 5
  • 43
  • 98
3
votes
3 answers

How to insert UIButtons of Dynamic size into a UIStackView dynamically?

This is working great: let label = UILabel() label.text = VARIABLE_LENGTH_STRING stackView?.addArrangedSubview(label) but this does not work let button = UIButton() …
Michael Economy
  • 608
  • 6
  • 21