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

UIStackView rounded corners for deployment target 12.3

I can easily create a stackview with rounded corners in iOS 14 by doing: stackView.layer.cornerRadius = 10 stackView.clipsToBounds = true without doing anything else. But since I want my app to also work on iPhone 6 that can't go beyond iOS…
Kaplan
  • 91
  • 1
  • 11
1
vote
1 answer

UIStackView spacing not working for nested stack views with baseline alignment

I'm attempting to include a series of UITextFields, with corresponding UILabels, in a vertical UIStackView. I'm nesting each label/field pair in a horizontal UIStackView, and the width of the labels is hard-coded to the widest intrinsic width of…
Son of a Beach
  • 1,733
  • 1
  • 11
  • 29
1
vote
1 answer

Content Hugging Priority with 2 views

I have 2 views, yellow & green. I want the yellow view to take up 70% of the space and green 30%, so 70:30. I embedded both in a stack view and gave the stackview constraints, bottom, left, right and height. I want to achieve the yellow box taking…
1
vote
0 answers

Why does one of my buttons in my StackView not show? The settings are the same as a button that does show

I have a horizontal stack view with 2 buttons. The settings for the 2 buttons are identical to my knowledge, but the button on the left does not show at all. This seems like a display issue, as clicking on the (invisible) button still completes the…
amirbt17
  • 533
  • 1
  • 4
  • 13
1
vote
2 answers

UIStackView show/hide animation is not working properly

I'm using UIStackView and it contains 3 UIView instances, which has fixed height I'm trying to hide these subviews by clicking button first and second view show/hide well with proper animation but last view doesn't animate class ViewController:…
PrepareFor
  • 2,448
  • 6
  • 22
  • 36
1
vote
1 answer

UIStackView accessibility - Insert an accessibility view in default accessibleElements?

Now learning that UIStackView's accessibility behaves by default reads the arrangedSubviews in order when voice over is on. Assume I have this hierarchy: UIView - UIStackView -view1 -view2 -view3 -view4 -…
janusfidel
  • 8,036
  • 4
  • 30
  • 53
1
vote
1 answer

Swift how to put vertical UIStackview / UIView inside horizontal UIStackview programatically

I am trying to put two UIViews inside a horizontal UIStackview. Inside the UIViews are Vertical UIStackviews to space the text (See picture for example). The vertical stackviews in the UIView is working. When I try to add the two UIViews to the…
Mashiba Sakuto
  • 213
  • 4
  • 15
1
vote
1 answer

UIStackView distribution with intrinsic content size of one subview prioritised

stackView +------------+ + | topView | height: 50 | +------------+ | | | | | | | total height: 300 | bottomView | height: 250 | | | …
1
vote
1 answer

StackView with two labels doesn't wrap content

I have one StackView with two labels inside. I want to place the two labels one next to the other. private lazy var stackView: UIStackView = { let stackView = UIStackView() stackView.translatesAutoresizingMaskIntoConstraints = false …
Gabriel Muñumel
  • 1,876
  • 6
  • 34
  • 57
1
vote
1 answer

Dynamic height of a UIView inside a UIStackView

Note: Similar questions have been asked on this topic but for some reason, the solutions mentioned in them doesn't seem to work for me so I'm posting this. I have a UIScrollView that fills the entire view of a view controller and a vertical…
Isuru
  • 30,617
  • 60
  • 187
  • 303
1
vote
1 answer

Label's height behaving strangely when put inside UIView in a stack view

I have a collection view cell. Inside this cell, I have a stack view with two labels. One is static height and one is dynamic height. If my hierarchy is as follows: - Stack view (distribution = fill) - Label (vertical hugging = 250) - Label…
user86516512
  • 445
  • 4
  • 13
1
vote
1 answer

UIstackview how to make sure two child view have different propotional size

I have an UIStackview which has two views. I want view1 to have 70 percent of parent when axis is vertical and I want view2 to have 70 percent when axis is horizontal. I tried to achieve this by playing horizontal hugging and resistance of two…
Amogam
  • 321
  • 5
  • 20
1
vote
1 answer

Button in UIStackView not clickable

I'm trying to add a button to my stack view. The button has a buttonTapped method that should be called when it is tapped. The problem is it is never being called, the button does not seem to be clickable. class CustomButton: UIViewController { …
ffritz
  • 2,180
  • 1
  • 28
  • 64
1
vote
1 answer

StackView layout side by side & on Top of each other (like zStack)

I currently have this interface whereby I am putting a MapView and a UIView on top of each other. The UIView is where I put my chart overlay (eg: Heart Rate). This is fine when the device is in portrait mode. However, I would like to explore a…
app4g
  • 670
  • 4
  • 24
1
vote
1 answer

UISlider in not working properly in UIStackView

Let me explain what I want to achieve. I want to create a slider and horizontal list of buttons inside UIStackView and UIScrollView so that buttons can scroll and then UISlider and UIScrollview will be placed inside vertical UIStackView. But the…
user2572661
  • 132
  • 1
  • 7