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

How to add and remove UILabels in UIStackview

I want to add and remove the UILabel in the UIStackview. The number of added UILabel will be depend on the length of string(eg. if string is SMITH the it should add 5 UILabel in the UIStackview. As user will click on next button the all 5 UILabel…
sham
  • 115
  • 9
2
votes
1 answer

UiTextField inside UiStackView is not responding

Goal: I'm building a time sheet using swift ui. Question: At the top I have class A that inherits from UiViewController. It lays out a UiStackView in a vertical stack to divide the screen into three: top,center,bottom. I'm having issues inside the…
EvOlaNdLuPiZ
  • 600
  • 1
  • 4
  • 21
2
votes
1 answer

Constraints for two UIStackView - one under the other

I working on "Hangman" app. On the top I want image, in middle textfield, and bottom couple UIStackView row for letters. Now I try to add constraints for only two UIStackView one under the other, but one is always behind other ie. not see. This is…
Hrvoje
  • 696
  • 7
  • 22
2
votes
2 answers

UIStackView - Positioning Image up against edge of sibling

I am trying to create a custom UITableViewCell in iOS that contains a Label and a related image. The image needs to be as close the the trailing edge of the label as possible. Below is an image of the progress so far.The Red area is the Horizontal…
Pat Long - Munkii Yebee
  • 3,592
  • 2
  • 34
  • 68
2
votes
1 answer

make horizontal stack view children center in iOS

I have a horizontal stack view which has two children. one is a label the other is an image with fixed size. in most situations the sum of their widths is less than stack view width. What I want is: (- is the space) -----Label-Image----- I…
Fattaneh Talebi
  • 727
  • 1
  • 16
  • 42
2
votes
1 answer

UIStackView works nicely in iOS 12, but not in iOS 11

In iOS 12, my horizontal stack view (with three elements) lays out just fine: But in iOS 11, the three elements stack on top of each other: Here is the view controller that holds the collection view, with a single row that contains the…
coco
  • 2,998
  • 1
  • 35
  • 58
2
votes
5 answers

Programmatically get the custom UIViews embedded inside UIStackView

In my ViewController, I have 12 custom UIViews(named CardView). I am trying to iterate through the subviews of the ViewController programmatically to find the custom view(CardView) and do some configuration. Following is my code to count the number…
Natasha
  • 6,651
  • 3
  • 36
  • 58
2
votes
4 answers

Detecting taps in UIStackView spacing (between items)

I'm trying to detect when a user taps between items in a UIStackView. Subclassing UIStackView and overriding hitTest and pointInside doesn't work. Those only get called when I tap on an item. Is there any way to achieve this? Thanks!
GSD
  • 149
  • 6
2
votes
1 answer

StackView's horizontal distribution is not working

I put three vertical stack views to a horizontal stack view. Although the distribution of the horizontal stack view is set to Equal Spacing, the second vertical stack view is aligned to left on a simulator(The first one is aligned to left and the…
2
votes
2 answers

Adding to UIStackView in a UITableView from the background thread

I have a UITableViewCell that has a horizontal UIStackView inside it. Creating and adding in the UIViews to the stack view is causing a bit of a performance issue. There's a definite blip in the scrolling of the table view. I've profiled it in…
Mr.P
  • 1,390
  • 13
  • 35
2
votes
1 answer

Button Constraints within a StackView (Swift Programmatically)

I'm new to setting up StackViews and Buttons programmatically. I am getting some strange behavior with my constraints I cannot figure out what I'm doing wrong. It feels like I'm missing something simple. Any help is greatly appreciated! I am…
Ben
  • 3,346
  • 6
  • 32
  • 51
2
votes
3 answers

How to increase UIView height which contains UIStackView

I have a custom view which contains a label, label can have multiple line text. So i have added that label inside a UIStackView, now my StackView height is increasing but the custom view height doesn't increases. I haven't added bottom constraint on…
Programming Learner
  • 4,351
  • 3
  • 22
  • 34
2
votes
1 answer

Dynamic width size to fit of controls in stackview

I have a horizontal stackview with button and label Case 1: Button text is dynamic and size of it should fit to text. So I added hugging and compression to required. This works perfectly Case 2: But when my label is hidden, Button takes entire space…
Ashh
  • 569
  • 1
  • 6
  • 28
2
votes
3 answers

How to set background color of UIView inside of UIStackView?

I am making a Detail screen which has several nested views in the Storyboard View Controller: ScrollView > UIView > StackView > 5 UI Views. Each UI view is a different section that contains labels and edit texts. When I set the background of one of…
Chris
  • 43
  • 2
  • 8
2
votes
1 answer

Populate UIStackView with UIButtons using array of Strings

I'm trying to create a UIStackView with some UIButton's. I have a an array of Strings that contain the button text. I Was trying to map over that array, creating an array of buttons. Then I could use forEach on that array to add…
Harry Blue
  • 4,202
  • 10
  • 39
  • 78