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

iOS - Different stackviews for size classes

I'm using UIStackView for layouting in one of my tableview cell xibs to make resizing easier, and I'm also using size classes as there are layout differences between phones and tablets. Due to some reason, I have to use a different stackview for…
Shawn
  • 311
  • 2
  • 9
2
votes
1 answer

Label's content is being cropped in a stackview

I am showing two labels in a stackview as shown in the image below. I would like the first label to show its full content. For this, I tried making its horizontal content hugging priority as well as its horizontal content compression resistance…
Sujal
  • 1,447
  • 19
  • 34
2
votes
1 answer

Placing Labels above UISlider using UIStackView

We are trying to find storyboard-only solution for the following scenario: We want to set "milestones"/"steps" labels above UISlider. The thumb location at value of 0.2 should be exactly at the middle of the correspond labels above it. It's…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
2
votes
1 answer

UIStackView ambiguous layout when all arranged subviews are hidden

I have a very very simple stackView: stackView.spacing = 10 stackView.axis = .horizontal stackView.alignment = .center stackView.distribution = .fill view.addSubview(stackView) stackView.snp.makeConstraints { (make) in …
2
votes
0 answers

Resizing UIStackView Based on Label Height Does Not Reflect in View

My app displays business information in a tableView and mapView. In the tableView, I measure the size of the text that populates the business name label and adjust the cell height appropriately for longer names in a custom heightForRowAt function.…
Pigpocket
  • 449
  • 5
  • 24
2
votes
2 answers

Auto-layout issue with stack view and label's font size

I really wanted to figure this out by myself but it's been 3 hours now and I don't think this kind of problem is worth half that amount of time so here I am seeking for help. This is an auto-layout problem so I will try my best to illustrate it…
Wizzardzz
  • 781
  • 1
  • 9
  • 32
2
votes
1 answer

How to add an UIImageView programmatically into a UIStackView (Storyboard)

I've designed the layout mostly in Storyboard. However now I want to remove/hide a UIButton (storyboard) for then to add a UIImageView instead programmatically. I've managed to hide the UIButton programmatically, but struggle to show the…
2
votes
2 answers

How to arrange views in the `UIStackView`?

I want to set four views in the UIStackView with the horizontal direction. The four views next to each without space. My code: let arrangeStackView = UIStackView() let followUpActionView = UIView() let developCurriculumView = UIView() let…
jiexishede
  • 2,473
  • 6
  • 38
  • 54
2
votes
1 answer

Layout two UILabels at each end of horizontal UIStackView

I'm trying to layout two UILabel in a horizontal UIStackView but I can't get it to work. As you can see label2 (red) is not using the remaining width from label1. Here's code you can add in a Playground: import UIKit import PlaygroundSupport let…
Peter Warbo
  • 11,136
  • 14
  • 98
  • 193
2
votes
0 answers

UILabel in UIStackView in UITableViewCell with numberOfLines = 0

I have a UITableViewCell, with an UIImageView and a UILabel, inside a UIStackView. I want the distribution for the UIStackView to fillProportionally. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) ->…
nouatzi
  • 735
  • 4
  • 14
2
votes
1 answer

Divide stackview in three subviews with a dashed divider line?

I'm trying to divide a UIStackView intro three separate subviews and have them divided by a dashed line. I know you can set spacing on a UIStackView but as far as I'm aware you cannot change that spacing to be a dashed line. Basically I want my…
SliceOfLife
  • 89
  • 2
  • 7
2
votes
2 answers

UIStackView subviews with size classes

Trying to achieve UIStackView with 2 labels for iPhone and 3 labels for iPad using size classes. View hierarchy Default size class [UIStackView] [UILabel 1] [UILabel2] [UIStackView] RxR size class [UIStackView] [UILabel 1] [UILabel2]…
Bilal
  • 18,478
  • 8
  • 57
  • 72
2
votes
1 answer

Multiline UIStackView / Break line if necessaries Xamarin.iOS

I'd like to create some buttons (or UILables) and list them in a line and if necessaries, it breaks line automatically. Just like this image : what I want So, as I use IOS 9+, I've added a UIStackView and inside it I've added my buttons, but I…
Alireza
  • 107
  • 5
2
votes
2 answers

Xcode How to create a square button(width equal to height) inside a Horizontal stackview

I have a requirement to create 3 square buttons at bottom of the page. All of them must be aligned and their size should be square. So far, I have created a horizontal stackview and created autolayout constrains 50 from the left, 50 from the right,…
Feroz Siddiqui
  • 3,840
  • 6
  • 34
  • 69
2
votes
1 answer

Embedding three UILabels in a horizontal UIStackView gives different results in a table view

For a week I have been struggling with a 'simple' piece of layout in a storyboard. I want three labels which all have numberOfLines set to two. The UIStackView has some constraints to position it in the table cell. The two left labels have a width…