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

UIStackView with Size Class

I looked at UIStackView and I don't understand how it can be used with the Resize Class. I would like to have a imageView and a textView inside stackView in vertical (portrait) mode. I would also like to have the same thing, but in horizontal…
Cristiano Alves
  • 233
  • 1
  • 13
3
votes
1 answer

Inserting UIHostingController with changeable height into UIStackView

I have an issue where I'm trying to insert a SwiftUI view into an existing UIKit view. The SwiftUI view can change height dynamically, but the UIStackView does not adjust to the new size. I've created a (hideous) test project to highlight…
DevB1
  • 1,235
  • 3
  • 17
  • 43
3
votes
1 answer

How do I disable UIStackView default show/hide animation?

This might be a strange question. We get the animation for free in a UIStackView when we show or hide a view inside it. But this behaviour is conflicting with another animation that I have. So is there a way to disable the default animations for…
rickrvo
  • 543
  • 3
  • 17
3
votes
2 answers

Swift: UIStackView Overlapping all Views instead of Stacking them Vertically

I am trying to create a statistics page for my app that will have various charts that are created dynamically depending on the type of data the user has. To do this, I am stacking multiple ViewControllers according to this tutorial:…
Ian
  • 113
  • 1
  • 6
3
votes
2 answers

Swift: Stack View not showing complete subviews

I have a subview: Here is the sub class of that view: class MyView: UIView { public init(){ super.init(frame: .zero) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } } On my main view…
user2924482
  • 8,380
  • 23
  • 89
  • 173
3
votes
3 answers

How do I make UIStackView's elements center alignment

What I want to achieve How do I make the elements to the center of UIStackview under the below condition? Using Storyboard Axis is Horizontal Alignment is Fill Distribution is Fill Spacing is 0 UIStackView have three UILabels that have different…
Capotasto
  • 131
  • 3
  • 17
3
votes
1 answer

Label doesn't seen in horizontal UIStackview when other elements are too wide

I have a horizontal UIStackView. Which has below elements; UILabel - UILabel (lets call it second label) Second label has a adjustsFontSizeToFitWidth = true property and a minimum scale factor. When It has a so long text, It gets shrink to some…
Emre Önder
  • 2,408
  • 2
  • 23
  • 73
3
votes
3 answers

Remove custom spacing in UIStackView

I have a stackview with three subviews: stackView.spacing = 8.0 stackView.addArrangeSubview(view1) stackView.addArrangeSubview(view2) stackView.addArrangeSubview(view3) At some point, I add custom spacing after…
BlackWolf
  • 5,239
  • 5
  • 33
  • 60
3
votes
0 answers

Disable Scrolling of specific stack in UIStackView

I am trying this method of using UIScrollView and UIStackView to add multiple child VCs. The first childVC in my vertical stackView is a straightforward set of labels, and has height of around 150 points. The second childVC under the first childVC…
3
votes
3 answers

UIStackView show/hide animation

In stack view I have UIPickerView and I want to collapse and expand it on button taps. I want to use a simple animation but don't know how to achieve it, I have tried many ways but none of it lead to the correct appearance I always get to this I…
eja08
  • 4,600
  • 3
  • 13
  • 19
3
votes
1 answer

Displaying UIStackView in UITableView cell programmatically

I want to display horizontal UIStackView with 3 labels in it, but I can't see the labels... override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) let stackView =…
Bogdan Bogdanov
  • 882
  • 11
  • 36
  • 79
3
votes
2 answers

IQKeyboard not showing next/previous options inside stackview

I am not able to see the next/previous button in toolbar using IQKeyboardManagerSwift when its inside stack view I have checked this link and added IQPreviousNextView as my view class. But still facing the same issue. Below is my storyboard…
Francis F
  • 3,157
  • 3
  • 41
  • 79
3
votes
1 answer

UIStackView in UIScrollView not scrolling

I am having a bit of trouble implementing a UIStackView in a UIScrollView. My view hierarchy looks something like this: ┌─────────────────────────────┐ │ViewController │ │┌───────────────────────────┐│ ││Spacer UIView …
Joseph
  • 9,171
  • 8
  • 41
  • 67
3
votes
1 answer

Swift - StackView in ScrollView doesn't scroll

I am trying to make a scrollable stack view inside a scrollview but it doesn't work. I have built a structure like this: If you can't see the image, this is the structure: UIScrollView constrained to superview in all 4 directions UIStackView…
Casper Lindberg
  • 600
  • 1
  • 6
  • 21
3
votes
2 answers

Trying to enumerate an array

I have mainStack as a UIStackView. This stack contains 4 UIStackViews. Each of these two 4 stacks contain 2 buttons. I am trying to locate these buttons by enumeration, using this code: // get the subviews of the main stack let subviews =…
Duck
  • 34,902
  • 47
  • 248
  • 470