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

Whats is wrong with UIStackView layout?

UIKit is making me feel like extremely frustrated. I have this little piece of code in Xcode playgrounds: let views = [UIView(), UIView(), UIView()] for view in views { view.backgroundColor = UIColor.blueColor() view.bounds.size =…
Earl Grey
  • 7,426
  • 6
  • 39
  • 59
3
votes
1 answer

Nested UIStackViews in UITableViewCell, slows down the scrolling, reduce performance. How do I improve performance?

I am using nested UIStackViews in my UITableViewCell. However, when I scroll it is very slow and affects the performance greatly. Is there any way that I can improve performance of nested UIStackViews in UITableViewCell? This is how I add my stacks…
The Cook
  • 1,403
  • 3
  • 17
  • 33
3
votes
0 answers

UICollectionView as arranged sub view in UIStackView

I have set up vertical UIStackView with couple of UIView's and UIColectionView. Everything works fine until I hide UICollectionView. When I unhide UICollectionView by setting NO for .hidden property. Collection view resizes properly with…
3
votes
0 answers

UIStackview horizontal alignment with 2 rows

I've a horizontal stackview which has a stackview as a subview with 2 labels. Alignment & Distribution are set to Fill in Xcode Attribute Inspector. I want to display 7 subview stacks inside the stack view with 4 in first row and 3 in second row…
Zoombie
  • 31
  • 3
3
votes
2 answers

How to make UIStackView scroll with UIScrollView programmatically?

I have seen several solutions to make UIStackView scroll with UIScrollView but they all rely Autolayout and IB. Is there a way to do it programmatically? I have seen this example: https://gist.github.com/twostraws/a02d4cc09fc7bc16859c But it uses…
Foobar
  • 7,458
  • 16
  • 81
  • 161
3
votes
2 answers

Nested Stack Views: Child Stack View is not inside its parent stack view when attaching it programmatically

I'm trying to implement nested stack views in which one stack view is inside another stack view. I've based my code here. My current code is here below. @IBOutlet weak var verticalStackView: UIStackView! let blueImageView =…
jhnferraris
  • 1,361
  • 1
  • 12
  • 34
3
votes
2 answers

Using StackView on different sized buttons

I am having problems using stack view with different sized buttons. This is what I am trying to achieve with StackView I'm having issues with stack view because buttons '=' and '0' are different size. This is what I've managed, but you can see the…
breaktop
  • 1,899
  • 4
  • 37
  • 58
3
votes
1 answer

Xcode: Stack View Move to next line if screen is too small

Using Stack View, I want to get 3 items next to each other, which I achieved: However, what I am looking to do is if the screen is too small to fit everything nicely in, then to move the block to the next line such as: Should I not be using Stack…
Snorlax
  • 4,425
  • 8
  • 37
  • 68
3
votes
0 answers

How to change the size of UIStackView on storyboard?

I use UIStackView on storyboard and put two UIButton on the stack view. However, once the buttons are added to the stack view, it seems that I cannot alter the frame of the stack view. For your information, I can move the stack view on the canvas;…
Blaszard
  • 30,954
  • 51
  • 153
  • 233
3
votes
2 answers

How to evenly space two subviews around the center of UIStackView (iOS 9)?

How to evenly space two subviews around the centre of UIStackView in the vertical axis? Currently both labels are next to the top and the bottom of the StackView. The stack view is the greyed area on the simulator screen shot. How to make them…
Tomasz Nazarenko
  • 1,064
  • 13
  • 31
3
votes
3 answers

UIStackView subclasses written in Swift may crash due to unimplemented init(frame:)

I have written a UIStackView subclass, but I am experiencing a strange run-time problem. Here is some sample code where it can be seen: class SubclassedStackView: UIStackView { init(text: String, subtext: String) { let textlabel =…
Clafou
  • 15,250
  • 7
  • 58
  • 89
3
votes
1 answer

UIStackView layout issues when changing size class in UITableViewCell

I'm having layout issues with my horizontal UIStackView in a custom UITableViewCell when showing/hiding arrangedSubviews when the horizontalSizeClass changes. My stack view contains a number of subviews, each of which, depending on cell…
beebcon
  • 6,893
  • 5
  • 25
  • 27
3
votes
2 answers

Align two labels bottom and top in Vertical UIStackView

I have the following table cell prototype: I would like to align the two labels in the stack view closer to each other. Something like align the "Label Table" to the bottom and align the "Label Event Location" to the top. I've tried setting the…
Maurits van Beusekom
  • 5,579
  • 3
  • 21
  • 35
3
votes
0 answers

Stack View Generated Constraints Breaking

I have a view controller with several stack views nested inside of each other. The storyboard looks fine, everything lines up perfectly. But at run time I get the following output. 2016-02-15 15:08:32.330 WVSurvey[97389:14208896] Unable to…
Cody Harness
  • 1,116
  • 3
  • 18
  • 37
3
votes
1 answer

iOS UIStackView unable to simultaneously satisfy constraints if set hidden

I have a problem referring to an UIStackView. I created a StackView and added a few items bundled into another StackViews to it. Now I want to animate the inner StackViews with the hidden attribute to switch between different objects. For that I…
user4947869