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
18
votes
2 answers

Expand UITableView to show all cells in Stack View?

I am having trouble getting my UITableView to appear full height in my Stack View. My view tree looks as follows: - View - Scroll View - Stack View - Table View - Image View - Map View The table view is dynamically populated…
Andre M
  • 6,649
  • 7
  • 52
  • 93
18
votes
2 answers

First Baseline and Last Baseline Properties in UIStackView

What effect do the First Baseline and Last Baseline properties have on the subviews of a UIStackView? Generally, can someone please illustrate the implementation of these values?
Burhanuddin Sunelwala
  • 5,318
  • 3
  • 25
  • 51
17
votes
3 answers

Horizontal UIStackView with two label (one multiline label, one one-line)

I have a horizontal UIStackView which has two UILabel in it. First UILabel is multiline (two line) and other one is one line only. They both have default content compression and resistance priorities. My problem is that even there is a gap between…
Emre Önder
  • 2,408
  • 2
  • 23
  • 73
17
votes
1 answer

Hiding the subview in UIStackview in ios

In order to hide a subview in UIStackView is it better to set the isHidden to true or to use removeArrangedSubview and remove the subview from the parent Stackview instead ? I am using a Stackview to arrange my UIElements in the tableView cell. I…
jay
  • 182
  • 1
  • 1
  • 7
17
votes
5 answers

What's the difference between a UIStackView And A UICollectionView in Xcode 7?

What's the difference between a UIHorizontalStackView and a Collection View(Also Vertical stackview)? Can't a collectionView be horizontal and vertical? Why would people use both? What does a UIStackView do that a Collection View can't?
nachshon f
  • 3,540
  • 7
  • 35
  • 67
16
votes
1 answer

Wrap items in a horizontal UIStackView on multiple lines

I am working on an iOS app which display a UITableView of items. Each row will show a list of tags with different widths(given by the tag's text length). I can place all the tags in a horizontal UIStackView but I want them to wrap on multiple lines…
sheitan
  • 1,076
  • 12
  • 27
16
votes
3 answers

UIStackView - Want a percentage to define each item

I want to put two views into a UIStackView. I want the top item to always be 30% of the space no matter what device (or orientation) that it appears. Thus, I want to have the bottom view to be 70%. How do I tell a UIStackView that I want to use a…
user3615480
  • 175
  • 1
  • 4
16
votes
1 answer

determining the intrinsic size of a UIStackView before display on the screen

I would like to determine the instrinstic size of a stack view before displaying it on the screen. The idea is to use it as part of a pull up menu from the bottom of the screen but when I query the object before it appears it has size (-1,-1). Is…
drw
  • 943
  • 1
  • 10
  • 25
15
votes
3 answers

height and vertical position are ambiguous for UIStackView

Autolayout cannot figure out the height or vertical position of a UIStackView despite having added subviews. This is a pretty common error and "gotcha" so please see the answer below.
SparkyRobinson
  • 1,502
  • 1
  • 15
  • 24
15
votes
5 answers

UIStackView; Equal Spacing Between & Outside Elements

UIStackView is awesome, I love Equal Spacing Distribution. But how to achieve the same space also outside of elements dynamically? In my case all elements will have same ratio 1:1
Adam Smaka
  • 5,977
  • 3
  • 50
  • 55
15
votes
3 answers

How to set weight in UIStackView in IOS

UIStackView is similar to Android LinearLayout but I could not figure out how to set weight for the subviews. Suppose I have a vertical UIStackView and 3 UIImageViews in it. I want to set weights 3, 6, 1 consecutively for the UIImageViews. How do I…
Asim Roy
  • 9,915
  • 4
  • 28
  • 40
15
votes
3 answers

How to properly add an UIImageView inside an UIStackView

My UIImageView is loaded with a picture with a high resolution. When I add the UIImageView to the UIStackView, the stack view will grow up to 1900x1200 dimension. The UIImageView contentMode is set to Aspect Fill. What can I do so that the image…
Adrian
  • 19,440
  • 34
  • 112
  • 219
14
votes
2 answers

Force a view to take as much space as possible inside UIStackView

I'm creating part of my application's UI with Swift and the problem I'm facing is I have a UIStackView with 3 sub views: 2 UILabels and an UIImageView. Here is my first code let switchview = UISwitch() let nodelableview =…
Amir_P
  • 8,322
  • 5
  • 43
  • 92
14
votes
4 answers

UIStackView Distribution Fill Equally

So, I have a UIStackView that contains four (4) UIViews. If I remove one (1) of those UIViews, the other three (3) will fill the entire space in the UIStackView. MY QUESTION: How can I add a max height on a UIView so that it won't fill the entire…
Bnj
  • 143
  • 1
  • 11
14
votes
2 answers

Why is this Stack View layout ambiguous?

I'm trying to create a relatively simple (!) layout with iOS 9 Stack Views. This is the Storyboard: With the following layout: But it's ambiguous: Titles Stack View: Need constraints for: X position or width, Times Stack View: Need constraints…
Robert Atkins
  • 23,528
  • 15
  • 68
  • 97