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

Can UIStackView also be used within a UITableViewCell?

Can UIStackView be used to resize, reposition, or collapse views within a UITableViewCell?
user4151918
21
votes
5 answers

Stackview exchange or change order of views

Stackview containing array of textfield is embedded in scrollview. I want to change the order of the text fields on some actions. The way to remove and add the textfield results in distorted view. I also tested by removing from scrollview. Normal…
Ankish Jain
  • 11,305
  • 5
  • 36
  • 34
21
votes
1 answer

Resize UICollectionView to content size

Summary: I have a child view within a stackview and that child view that is programatically sized. It has a couple of empty views to fill up the empty space. At runtime, however, attempts to resize the child don't work and it remains the same size…
dave
  • 1,567
  • 2
  • 21
  • 34
21
votes
5 answers

Swift: Disappearing views from a stackView

I have a fairly simple set up in my main storyboard: A stack view which includes three views The first view has a fixed height and contains a segment controller The other two views have no restrictions, the idea being that only one will be active…
Ben
  • 4,707
  • 5
  • 34
  • 55
21
votes
13 answers

Unresponsive UIButton in subview added to UIStackView

In the detailViewController of a UISplitView I have subviews added to a UIStackView inside a UIScrollView. Just using system buttons without subviews or images, results in responsive buttons, but subviews seem to interfere. Enabling touch is…
Jolly
  • 263
  • 1
  • 2
  • 7
20
votes
1 answer

UIStackView inside UICollectionViewCell autolayout issues after running on Xcode 10 beta

My stack view contains an image and label to display some tasks. They were all left aligned on multiple rows. I didn't have any issue running on Xcode 9, but when I run on Xcode 10 beta 6, I get some autolayout issues, I always get errors like for…
Adrian
  • 19,440
  • 34
  • 112
  • 219
20
votes
3 answers

Resizing Button within a stackview

So I've be studying Swift/iOS development recently and I'm having a little trouble with sizing buttons within a stack view, I have the following layout: There are two TextFields and a button in a vertical StackView, the StackView is centred…
Mrk Fldig
  • 4,244
  • 5
  • 33
  • 64
20
votes
5 answers

Xcode - Swift, UITextView won't display on UIStackView

I know that there's a question similar to this already, but his solution didn't solve my problem. What I have is, I've used the storyboard to create a view controller, and then place a child stack view ontop. Using IBOutlet, I've linked the…
HumbleWebDev
  • 555
  • 4
  • 20
20
votes
3 answers

UIStackView's own intrinsicContentSize

I'm using the UIStackView with the following configuration: let contentView = UIStackView() contentView.distribution = .EqualSpacing contentView.alignment = .Center contentView.spacing = horizontalSpacing Each of the elements has it's own…
simonseyer
  • 650
  • 1
  • 7
  • 14
20
votes
4 answers

Adjusting UIView Height Inside UIStackView Control

I am using a UIStackView in iOS 9 SDK. The height of the stackview is 44 points. I have a UILabel and UIView inside the StackView as shown below: Now, I want to make the green view much smaller than 44.. much like 20. How can I do that? Without the…
john doe
  • 9,220
  • 23
  • 91
  • 167
19
votes
3 answers

UITextview inside UIStackView

I added my UITextView inside UIStackView. But my textview is not Multiline. Auto layout is shown as below: As per Image it is just taken 1 line. The textview frame shown as out of frame as per image. UITextView UIStackView
user2526811
  • 1,233
  • 4
  • 20
  • 54
18
votes
5 answers

UIStackView - hide and collapse subview with animation

I'm trying to hide UIStackView's subview like this: UIViewPropertyAnimator.runningPropertyAnimator(withDuration: 2.0, delay: 0, options: [.curveEaseOut], animations: { self.label.isHidden = true self.label.alpha = 0.0 …
Andrey Gordeev
  • 30,606
  • 13
  • 135
  • 162
18
votes
2 answers

UIStackView proportional layout with only intrinsicContentSize

I'm experiencing problems with layout of arranged subviews in UIStackView and was wondering if someone could help me understand what's going on. So I have UIStackView with some spacing (for example 1, but this does not matter) and…
Arthur Grishin
  • 338
  • 2
  • 10
18
votes
12 answers

iOS - Add vertical line programatically inside a stack view

I'm trying to add vertical lines, between labels inside a stack view all programatically. The desired finish will be something like this image: I can add the labels, all with the desired spacing; I can add horizontal lines but I can't figure out…
Ivan Cantarino
  • 3,058
  • 4
  • 34
  • 73
18
votes
8 answers

UIStackview align left

I'm trying to align the items in UIStackview horizontally to the left. Is there anyway to do this programmatically? I tried to do this via storyboard but was not successful. For some reason, the items in the UIStackView centers itself.
Yong Jia Pao
  • 181
  • 1
  • 1
  • 3
1 2
3
95 96