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 has no useful ReadableContentGuide

I am adding SubViews to a vertical UIStackView with AddArrangedSubView. By default those views are positioned at the Left and Right edges. I can set LayoutMargins = new UIEdgeInsets(top: 0, left: 15, bottom: 0, right:…
Pat Long - Munkii Yebee
  • 3,592
  • 2
  • 34
  • 68
1
vote
0 answers

UIStackView content shrinking when changing height constraint

My layout has a UIStackView which has multiple child stack views. The parent and child stackviews both have heightConstraint set. On a button tap I collapse the parent stackview to a certain height. But while collapsing, the parent stackview's…
1
vote
1 answer

iOS: Hide UIStackView SubViews

I have a small issue in mu UIStackView. I created a project similar in this guide: https://medium.com/@nrewik/easy-animation-with-uistackview-8878b2856ae2 and it works perfectly. Anyway if in the stackView there is only a subView it disappears on…
cyclingIsBetter
  • 17,447
  • 50
  • 156
  • 241
1
vote
1 answer

How can I create dynamic labels using UIStackView

I have 10 UILabels with different sizes, and I want to arrange them in 3 rows, and all rows have leading alignment, and if the last item of each row can't fit in remaining space of parent view, it have to move to the next line. How can I do that by…
NabiMo
  • 105
  • 9
1
vote
1 answer

Some tableView rows don't show unless I scroll but then disappear

I'm following (I did make some minor changes in how I do the constraints of the tableViewCell, I'm using a stackView instead) this RayWenderlich tutorial. It's about dynamic self sizing tableViewcells. My problem is that my tableView initially loads…
mfaani
  • 33,269
  • 19
  • 164
  • 293
1
vote
1 answer

Programmatically created horizontal UIStackView with 2 justified labels

I want 2 labels (say leftLabel, rightLabel) and place them horizontally such that leftLabel stretches and rightLabel just fits single character icon (say, ">"). Thus both labels layout justified. Like this... This is the code I have - class…
Ashok
  • 6,224
  • 2
  • 37
  • 55
1
vote
1 answer

How to position rotated UILabels inside a UIStackView with no gap?

I'm trying to create a UIStackView containing UILabels that have been rotated. The UIStackView is positioning the UILabels based on their non-rotated widths, such that there is a large gap when I would expect the UILabels to be directly adjacent.…
Software2
  • 2,358
  • 1
  • 18
  • 28
1
vote
1 answer

Tap detection UIImageView within UIStackView within UIScrollView

I'm having a couple of UIImageViews in horizontal UIStackViews, wrapped in a vertical UIStackView, all together packed into a UIScrollView. All UIxx elements have "User Interaction enabled" checked. My UIViewController tries to catch the taps like…
decades
  • 827
  • 17
  • 25
1
vote
3 answers

Add UIImageView, UILabel to UIStackView programmatically in Swift 4

I'm trying to create a set of UIImageView, UILabel and add to UIStackView programmatically like so. var someLetters: [Int: String] = [0:"g",1:"n",2:"d"] let stackView1 = UIStackView(arrangedSubviews:…
Seong Lee
  • 10,314
  • 25
  • 68
  • 106
1
vote
1 answer

StackView - center buttons with text below image

I am using this class for center text below icon for UIButton: @IBDesignable class TopIconButton: UIButton { override func layoutSubviews() { super.layoutSubviews() let kTextTopPadding:CGFloat = 3.0; var…
Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182
1
vote
0 answers

understanding layoutSubviews different behaviors

I have two group of buttons. They should have rounded rects for different screen sizes. so I wrote: override func layoutSubviews() { submitButton.layer.cornerRadius = updateButton.bounds.size.height / 2 cancelButton.layer.cornerRadius =…
mfaani
  • 33,269
  • 19
  • 164
  • 293
1
vote
1 answer

iOS how to do a layout with two fixed sections and a dynamic tableview?

I'm currently trying to create an iOS version of an application I previously made for Android. In the Android version, I had a LinearLayout where I could just throw in any additional layouts I needed (one of which was a RecyclerView for showing data…
markeh21
  • 189
  • 12
1
vote
3 answers

StackView different between Xcode Preview and Simulator

I am trying to figure out how to start using stackviews and running into issues where everything looks great in Xcode Preview, but then when I run it in the simulator or on a device it looks completely different. Here is my Xcode storyboard: And…
Nate23VT
  • 423
  • 8
  • 27
1
vote
1 answer

Vertically centering text with an image in a horiztonal stack view (AutoLayout) - iOS

I've been having some problems centering text vertically beside an icon in a horizontal stack view. Here are some facts: 1) I create a view to hold stack view - add constraints 2) I place a horizontal stack view inside of that view - add width and…
James Scott
  • 990
  • 2
  • 10
  • 29
1
vote
1 answer

Stack View not getting added as a subview programmatically

I have an array of buttons which I have added within a stackview, I need to add this stackView in one of my subview which is in another parentStackView. This is my code: let innerStackView = UIStackView(arrangedSubviews:…
Geet
  • 2,427
  • 2
  • 21
  • 39