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
1
vote
1 answer

Swift - How put a stack of views into a scrollview

Currently I have a custom view (returns a UIStakView) that contains many views (UILabel, UIImageView, ...). It displays fine - on devices with plenty of height. (BTW, this is all done programmatically.) On small-screen devices it will only show the…
1
vote
2 answers

How to access initializer for a custom CollectionView cell?

I have a collectionView with multiple cells. Each cell is of this class: class OuterCollectionViewCell: UICollectionViewCell { @IBOutlet weak var stackView: UIStackView! override init(frame: CGRect) { super.init(frame: frame) …
BigBoy1337
  • 4,735
  • 16
  • 70
  • 138
1
vote
1 answer

How to get the width value of an UIView which is inside an UIStackView

I have my own custom view, ProgressBar, which I create it programatically: let pb = ProgressBar(frame: CGRect(x: 0, y: 0, width: 200, height: 16)) I create it using a width of 200, but then I add this to a horizontal stack view. Because of this,…
Adrian
  • 19,440
  • 34
  • 112
  • 219
1
vote
0 answers

How to make expandable UITableViewCell with UIStackView

I had a problem with creating unfolding cells. I'm use a UIStackView. The problem is that when the cell is minimized, the lower view rides over the top and it turns out an ugly animation. here is my methods override func tableView(_ tableView:…
Manki
  • 11
  • 2
1
vote
1 answer

Objective-c: Dynamic size of UIStackView, depending of it's content

I have an UIStackView which is inside a scrollview. the content of the stackView is dynamic, depending of how much views created and added with the methode "addArrangedSubview". if I have a few subviews, there is so much spacing between them, and if…
Walid
  • 700
  • 2
  • 10
  • 29
1
vote
1 answer

StackView not shrinking when removing arranged subview

I have a vertical stackview with 7 subviews. When I remove one of the subviews the stack view doesnt shrink, but the view above the removed view occupies the freed space. I have tried subview.isHidden = true as well…
NataliaKh
  • 27
  • 7
1
vote
1 answer

UIStackView: Aspect fill image squashed issue

I have 4 images inside a UIStackView which is constrained 20pts from top, right, bottom, left. 4 images are set to Aspect Fit and the UIStackView settings are set to: Fill Equally, and Spacing of 20. When I come to view this on an iPhone 8 upwards…
user7684436
  • 697
  • 14
  • 39
1
vote
1 answer

Resizing subview containing image in UIStackView

A while ago I thought it might be a good idea to replace my own layout for a number of views inside a scrollview with a UIStackView. But after more than a week of frustration I'm asking for help: I'd like to place subviews like these: inside a…
mav
  • 85
  • 11
1
vote
1 answer

UIStackView layout issue with UILabel

I have two UILabel inside horizontal stack view with alignment top and distribution fill. The problem is second label is taking too much space rather than its intrinsic content size. I also had set content hugging priority of second label to .high…
noob
  • 545
  • 6
  • 23
1
vote
3 answers

UILabel breaks early inside UIStackView

Given the view hierarchy: UIStackView --UILabel --UISwitch The label breaks too early, even if it can be fit to a single line. Setting numberOfLines = 1 forces the label to be laid out correctly. How to make UILabel perform line break only when…
Richard Topchii
  • 7,075
  • 8
  • 48
  • 115
1
vote
1 answer

Stack View size change cannot be visualized

Within a regular UIView that uses basically all screen space I put a Stack View with vertical and horizontal alignment, and a constraint such that the images inside have the same size. Thus, I am expecting that once the size of the whole Stack View…
jmlipman
  • 172
  • 10
1
vote
3 answers

Stackview in navigation bar

Is it possible to place UIStackView in NavigationBar programmaticaly using swift? I want to place there StackView with two arranged stackviews. But when i do that , it shows nothing in navigation bar. If it is possible, please provide example.…
Rufat Abdul-zade
  • 115
  • 2
  • 11
1
vote
3 answers

How to put a uiview back in a stackview after I took it out?

I have a viewcontroller that holds multiple stackviews. There is a button that when pressed, the corresponding uiview wil become fullscreen inside the original view. There is a different button that is supposed to make the uiview go back to its…
Jer
  • 37
  • 6
1
vote
1 answer

Childview width anchor is not working inside stackView

I am trying to have maximum 3 views inside Stackview and all child views should be centre aligned ` for _ in array{ if(stackView.subviews.count != 3){ let image : UIImageView = UIImageView() …
Mithran
  • 301
  • 1
  • 3
  • 15
1
vote
1 answer

How do I change the height and width of StackView containing buttons from Storyboard?

I have a stack view containing several buttons, It seems impossible for me to change the dimensions of the stack view. The size of stack view is always fixed in Size Inspector: Even when I add constrains to the stack view, it just show warnings,…
S.S.D
  • 1,579
  • 2
  • 12
  • 23