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

Swift Nested Stack Views

Came form android background now trying to understand UIStackView in ios with simple login view example but got confused from distorted output. Following are my details: My Login view file: import UIKit import SnapKit class LoginView: UIView { …
Pushpendra
  • 2,791
  • 4
  • 26
  • 49
2
votes
0 answers

Multi-line Stackviews Programmatically In Swift

I'm working with a horizontal stackView composed of UIView subclasses. Right now, when the width of the stackView exceeds the width of the superview, the subviews truncate. What I'd want to happen is that the view that exceeds the width of the…
ArielSD
  • 829
  • 10
  • 27
2
votes
1 answer

Trying to make sense of UILabel behavior.

I am trying to replicate Apple's calculator UI layout. Here is a gif of what I have so far. The problems that I am encountering mostly have to do with the UILables. As seen in the gif above, I am experiencing the following problems: On device…
Biosx
  • 75
  • 1
  • 1
  • 7
2
votes
3 answers

UIStackView Weight like Linear layout

How to design the following layout with StackView I know that it can be easily created without using stackview but is it possible using stackview because i have lots of ui which already designed using stackview how can i add divider between…
Jaydeep Vyas
  • 4,411
  • 1
  • 18
  • 44
2
votes
5 answers

CollectionView Disappears within StackView (Swift)

I'm trying to achieve the stackView arrangement shown in the middle of this figure:, but for some reason the top stack, containing a collectionView, disappears when using: a .fill distribution stackView.distribution = .fill (stack containing…
Tony M
  • 1,694
  • 2
  • 17
  • 33
2
votes
2 answers

Set sort order for UIStackView

Is it possible to set a sort order for a UIStackView? For example, I want to sort it by time. Each subview has a time property which is just an Int. I know you can sort a UITableView by sorting the array and then refreshing the table but UIStackView…
Marcel
  • 1,034
  • 1
  • 17
  • 35
2
votes
1 answer

Keep subviews as original dimensions in UIStackView

Currently I'm trying to make 3 buttons in a horizontal group of 3 that have equal spacing UIStackView * menuButtons = [[UIStackView alloc] initWithFrame:CGRectMake(0, 0, 60, 16)]; menuButtons.axis = UILayoutConstraintAxisHorizontal; …
user286152
  • 117
  • 1
  • 2
  • 12
2
votes
2 answers

UIStackView resizing my views

Im making a custom keyboard, and wanting a label and a textField centered in the space left over the keyboard, I figured the proper way would be to incorporate them in a UIstackView, and then centering the stack. However, i'm having som issues with…
Lord Fresh
  • 636
  • 8
  • 15
2
votes
4 answers

Retrieve the right position of a subView with auto-layout

I want to place programmatically a view at the center of all the the subviews created in a storyboard. In the storyboard, I have a view, and inside a Vertical StackView, which has constraint to fill the full screen, distribution "Equal…
FredericP
  • 1,119
  • 1
  • 14
  • 27
2
votes
1 answer

How to use stack view to autolayout label and button?

How can I layout a label and a button inside a UIStackView in such a way that the button only takes as much space as it needs and the rest is left for the label? Button text could be various length due to localizations. The UIStackView here is…
h3dkandi
  • 1,106
  • 1
  • 12
  • 27
2
votes
2 answers

Bottom-align the text of a sequence of UILabels within a horizontal UIStackView

How do I programmatically align the text of a sequence of UILabels within a horizontal UIStackView so that all text is at the bottom of the views? Below is an image of what I have and what I want. I already know how to create the views, I just…
zkon
  • 568
  • 1
  • 6
  • 19
2
votes
1 answer

UIStackView seems to stack spacing even when arranged subviews are hidden

I have 5 elements in my horizontal stack view. At one point, I hide elements at index 1 and 2. I have a spacing of 1pt and it seems that when element 1 and 2 are hidden the spacing between element 0 and 3 is the sum of the spacing between element 0…
Plot
  • 898
  • 2
  • 15
  • 26
2
votes
1 answer

Proportionally distributed UIStackView in self sizing cell

I have two labels in a horizontal stack view. The labels have numberOfLines set to 0 so they will wrap infinitely, Vertical Content Compression Resistance set to 1000 so they will always be their full height, Horizontal Compression Resistance set to…
2
votes
0 answers

UIStackView animation

I am trying to animate playing cards between UIStackViews and have spent countless hours trying to get it right. I feel this should be pretty straight forward, but I haven't found any information to help me. Clip here:…
2
votes
2 answers

Hiding a UIStackView with nested UISTackviews

Preface: I took a peek at this post and it didn't solve my problem. Here's a link to a repo that shows the error I'm encountering. I have a UIViewController with a vertical UIStackView containing nested horizontal UIStackViews. There are two…
Adrian
  • 16,233
  • 18
  • 112
  • 180