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

Why does UIStackView not stack a UILabel arrangedSubview?

I have a UIStackView, and as arranged subviews, I have two UIViews, and a UILabel. The UIViews are stacked one after another, while the UILabel is aligned to the leading edge of the subview. Code: let stack = UIStackView() stack.axis =…
rawbee
  • 2,946
  • 3
  • 18
  • 22
1
vote
2 answers

UIStackView spacing breaks constraints when not in set updateConstraints

I have a simple ViewController with a custom subview called MyView: import UIKit class ViewController: UIViewController { let myView = MyView() override func viewDidLoad() { super.viewDidLoad() …
Renato Stauffer
  • 738
  • 2
  • 14
  • 30
1
vote
2 answers

UIStackView distribution and alignment of a multiline UILabel

I' struggling with some basic UIStackView distribution and alignment stuff. I have an UICollectionViewCell which has a horizontal UIStackView at the contentView subview. This UIStackView has a vertical UIStackView for the three labels itself, and…
wj313
  • 85
  • 3
  • 7
1
vote
1 answer

Align view to bottom in UIStackView

I have two UIImageView and one UITextView. I want to align second image view bottom as below. How to get this?
dobiho
  • 1,025
  • 1
  • 11
  • 22
1
vote
2 answers

Center Vertically UIStackView inside UIScrollView with scroll

Hello it's been imposible to center a UIStackView inside a ScrollView having scroll working ... I've tried lot of things but the best one has been this: stackView = new UIStackView { Axis =…
CarLoOSX
  • 505
  • 3
  • 9
1
vote
1 answer

Automatically increase size of UIViewController containing a UIStackView

I am trying to achieve a pretty complex view hierarchy. My idea is to build a UI similar to the AirPods and HomePod configurator sheet showing from the bottom part of the screen. I have a fullscreen UIViewController which has a child view controller…
BalestraPatrick
  • 9,944
  • 4
  • 30
  • 43
1
vote
1 answer

stackView not expanding according to to the dynamic label content

I am using stackView to show the hierarchy shown in image1. The two labels are in vertical stack view and then this stack view with the image is combined in an horizontal stackview. I set the description label no of lines to 0 and make it…
Parv Bhasker
  • 1,773
  • 1
  • 20
  • 39
1
vote
2 answers

UIStackView within UIScrollView is cut off

I'm trying to use a UIStackView within a UIScrollView and I was hoping someone could point me in the right direction in creating the right constraints because I can't figure out what the problem is. These are my constraints and ViewController…
dylanvdb
  • 106
  • 18
1
vote
1 answer

Buttons in StackView not working - Swift

My problem is that the buttons in my Stackview don't work. I configured 6 buttons in Storyboard (user Interaction is enabled) and put them all in a stackview because I need them to organize automatically, when I hide one or more of the Buttons. But…
1
vote
0 answers

ImageView inside StackView moved to the edge of the screen on iOS 11

I've got a view that contains vertical StackView: Alignment - Fill Distribution - Fill Proportionally Spacing - 15 that contains several horizontal StackViews: Alignment - Fill Distribution - Fill Proportionally Spacing - 10 in which there is…
user3448282
  • 2,629
  • 3
  • 25
  • 47
1
vote
0 answers

Embedded Stackviews triggering autolayout error

I am using a series of embedded stackviews in the storyboard. I'm getting this error in the console and also noticing jittery scrolling in the table view. "This system of layout constraints is extremely difficult to optimize, taking 1014 pivots. …
GarySabo
  • 5,806
  • 5
  • 49
  • 124
1
vote
1 answer

UIStackView, make it give up .spacing in compression resistance?

Say you have a vertical stack view, it has three items, and the spacing is set to 50. It turns out to be 4 inches tall. It turns out it's going to compress to about 3 inches (say, when the keyboard comes up - whatever). You set CCRP to a low value -…
Fattie
  • 27,874
  • 70
  • 431
  • 719
1
vote
1 answer

Access the Stack view from a UIButton super view

I am attempting to get a UIButton's y coordinate position through the stack view that it belongs to. I need this value in the program to map the position of the button to a different coordinate system. Here is my code that will grab the button's…
philm
  • 797
  • 1
  • 8
  • 29
1
vote
1 answer

Constrain subview of UIStackView relative to stack view height

I have a vertical stack view which can contain 1-3 subviews. The subviews should have height about 1/3 of stack view height, even when there's only one or two of them. I tried adding: view.heightAnchor.constraint(equalTo: stack.heightAnchor,…
vortek
  • 474
  • 2
  • 14
1
vote
0 answers

App crashes when inserting UIButton into UIStackView

I have wired up a UIStackView in my storyboard and I am dynamically adding buttons to it, this works fine if I add one or two buttons but when I want to insert the third button the app crashes with the following error 017-12-27 10:41:14.315786+0800…
Matt Douhan
  • 2,053
  • 1
  • 21
  • 40