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

How to set custom heights on arranged subviews within a UIStackView?

I have a horizontal UIStackView with some arranged subviews, whose heights should be less than that of the StackView but centered along the StackView's y axis. However, even after setting constraints on the subviews, their height does not change and…
Kevin2566
  • 425
  • 8
  • 20
1
vote
2 answers

Proper Alignment and Distribution selection for Horizontal StackView

Following is the screenshot showing the design I want to implement. For this, I am using a vertical stackview that encompasses four other horizontal stackviews. Then each horizontal stackview includes an image and a label as indicated below. I set…
Sujal
  • 1,447
  • 19
  • 34
1
vote
0 answers

Is there a way to layout buttons dynamically in swift so that they "word wrap"

UPDATE: I am adding a photo that may better demonstrate the type of thing I am trying to achieve. I am creating an app where a user can set as many filters they like on a stream of images. I would like to display each filter they have set as a…
Daniel Patriarca
  • 361
  • 3
  • 20
1
vote
2 answers

How to add an array of UIButtons onto a UIStackview?

I am using the 26 letters of the alphabet and creating a UIButton with the respective letter, after I create the array of UIButtons I send the Array in which I store these buttons and I add it to a stack view. The stackview is also inside of a…
abcdefg
  • 97
  • 1
  • 9
1
vote
1 answer

Animation within arranged subview in uistackview "jumps"

I have a horizontal UIStackView containing several arranged subviews. I want to remove one arranged subview (let's call it A) when a user clicks on a button, but just before that I want to do a quick animation. I want to do my own animation so I…
Jerem Lachkar
  • 1,008
  • 11
  • 24
1
vote
0 answers

Unable to increase the height of UIView in relation to TextView

I used the vertical stack view to hold two UIView.Second UIView has a textArea.But I could not find a way to change the UIview height when the height of TextView change
Kasun
  • 21
  • 5
1
vote
1 answer

UIStackView distributing with equalCentering

I have created UIStackView programmatically and added 2 views that have 2 child views each. Here are my sample codes: let sv = UIStackView() sv.axis = .horizontal sv.alignment = .center sv.spacing =…
codelearner
  • 1,354
  • 1
  • 16
  • 32
1
vote
0 answers

Configure a dynamic height for UICollectionView within UIStackView that is nested within a UITableViewCell

I have a UITableView with different cells, within one of these cells is a UIStackView which contains multiple UIView's, the last one being a custom class that subclasses UICollectionView. So the issue I'm having is that the collectionview within the…
Tunds
  • 1,804
  • 2
  • 15
  • 30
1
vote
2 answers

How to recalculate constraints after device rotation

In my table view's cell I've stack view which contains views. I've trailing constraints for stack view. I calculate the value of this trailing constraints based on how many views I've to show inside stack view. Is there any way we can recalculate…
Davis
  • 105
  • 1
  • 12
1
vote
1 answer

RemoteViewsService onGetViewFactory not called

I'm sure I'm missing something simple here but onGetViewFactory is not calling while attempting to populate a StackWidget. I've gone over this multiple times and cannot find my error. The RemoteViewsService is being attached in updateWidget: public…
John Mack
  • 95
  • 1
  • 7
1
vote
1 answer

UITextField inside UIStackView Spacing Issue on width constraint

I have a vertical UIStackView which has various of UITextFields (Now It is only 4) inside it. When I give spacing to UIStackView, I gave below error; "
Emre Önder
  • 2,408
  • 2
  • 23
  • 73
1
vote
1 answer

UIStackView as flexbox with centered justified content

I've been trying to center some buttons in an horizontal UIStackView But doesn't matter what I do, the only not broken layout that I can get is basically: I added constraints to fix the button width programmatically, as the amount of buttons is…
Nuthinking
  • 1,211
  • 2
  • 13
  • 32
1
vote
1 answer

UIStackView equal spacing including edges

I have a horizontal stack view with 3 buttons: Backwards, Play, Forward for a music application. Here is my current code: self.controlStackView.axis = .horizontal self.controlStackView.distribution = .equalSpacing self.controlStackView.alignment =…
Janosch Hübner
  • 1,584
  • 25
  • 44
1
vote
0 answers

How to make stack view scrollable in landscape

I have a popover (alert) as a custom view (UIViewController). As subviews, in storyboard, I have a stack view with some labels and I added a scroll view as superview for stack view. In portrait mode it shows fine, but when moving to landscape I…
1
vote
1 answer

UIStackView - force label to be tight and view to be as wide as possible

I have UIStackView let sv = UIStackView() sv.axis = .horizontal sv.distribution = .fillProportionally sv.spacing = 2.0 sv.translatesAutoresizingMaskIntoConstraints = false Now I have added two elements (UIView and UILabel). If I run app, I have…
Martin Perry
  • 9,232
  • 8
  • 46
  • 114