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
0 answers

How to get rid of `UIStackView` magnificationFilter iPad warning?

I have very simple UIStackView with several buttons. Every time I run the app on an iPad I get this warning: - changing property magnificationFilter in transform-only layer, will have no effect The CATransformLayer…
Alexander Vasenin
  • 11,437
  • 4
  • 42
  • 70
2
votes
1 answer

What is wrong with that addArrangedSubview code?

I'm trying to understand how addArrangedSubview is working so I tried with a dummy project. Here's my VC : import UIKit class ViewController: UIViewController { @IBOutlet weak var stackOutlet: UIStackView! override func viewDidLoad() { …
petaire
  • 495
  • 1
  • 10
  • 23
2
votes
2 answers

UIView ignoring setHidden when in animation block

I have this code on an UIView subclass: override var hidden: Bool { willSet { DDLogDebug("Will set hidden=\(String(newValue)) on \(item?.name))") } didSet { DDLogDebug("Did set hidden=\(String(hidden)) on…
2
votes
0 answers

Shrink Element Inside StackView

I have a stack view that expands from the left edge of my screen to the right. Inside it, I have a label and a button. The height of the StackView is 40, and the button has a set width of 40. I'm loading an image into the button, but I would like…
Josh D.
  • 151
  • 1
  • 11
2
votes
1 answer

How to create gesture driven dynamic resizable view similar to instagram layout app

How can I make something like this : https://media.giphy.com/media/l0HlNCX30sTfsldAs/giphy.gif I know there were some open source libs for this but couldn't find it anymore.
mosn
  • 311
  • 3
  • 16
2
votes
1 answer

How do I dynamically adjust the height of a UIView when a member stack view is no longer shown?

I am super new iOS development and StackViews in general and need help calculating dynamic height in instances where a stack view will not be shown. There are cases where certain elements will not be shown depending on what I get back from the…
Aetherynne
  • 113
  • 3
  • 8
2
votes
1 answer

Arrange UILabels in UIstackView Dynamically

I am adding labels as subview to UIstackview using arrangedSubView property. what happens is that if I keep Stackview axis horizontal, I get one horizontal strip of UILabels label1 label2 label3 label4..... if I keep it vertical, I get a vertical…
Ranjit
  • 4,576
  • 11
  • 62
  • 121
2
votes
0 answers

UIStackView Overlapping but not stacking

I am pretty new to programming. The screen has two vertical columns and 3 boxes. A box will go to the left column if right column has less boxes then the left. And each box has several subviews. In my code, the "yearBOX" and "dayBOX" will go to the…
William Tong
  • 479
  • 7
  • 14
2
votes
2 answers

Floating view into second row with autolayout

Can I setup constrains on storyboard view controller views so that I will have three views one next to other when there is enough horizontal space. In other case it will "float" one of views to next line? Like on this example: Enough space Texts…
Fishman
  • 1,737
  • 1
  • 25
  • 42
2
votes
1 answer

Creating iOS UIStackView programmatically

How to create UIStackview programmatically? Is there any way to modify stack count dynamically?
Vinu David Jose
  • 2,569
  • 1
  • 21
  • 38
2
votes
2 answers

Dynamic UITableView cell height with UIStackViews

I am trying to create a dynamic height row using UIStackViews and autolayout, so below is my UITableViewCell xib. So as you can see it has all the stackViews inside it. I tried using estimated row height and the delegate functions. But nothing…
Ranjit
  • 4,576
  • 11
  • 62
  • 121
2
votes
0 answers

UIStackView - Removing styled label children causes crash

I'm getting crashes, sometimes when I try to remove all arrangedSubviews in a UIStackView. If I use only UILabel with no styling, it works fine. I have this function to remove the children: extension UIStackView { func…
Bjarte
  • 2,167
  • 5
  • 27
  • 37
2
votes
1 answer

Scroll view and Stack view

I've read everything I could find about stacks with scroll views but nothing helps me. I want to have vertical scroll because I have some labels in stack view and sometimes there are all labels sometimes there are not. According to this, I want to…
Kira
  • 1,575
  • 4
  • 26
  • 48
2
votes
1 answer

Snapping arranged views to top of UIStackView

I have a Vertical UIStackView with 7 elements inside. These elements are not collectively tall enough to fill the entire view, so they get spaced based on the distribution value. I would like the arranged views to stack at the top of the view, with…
Connor Hicks
  • 755
  • 2
  • 8
  • 25
2
votes
1 answer

XCode: Stack view and constraints

Why would I need contraints on elements that live inside my stack view? Is not the idea of the Stack View to stack elements automatically thus making the need of explicit measures to be added?
Helmut Granda
  • 4,565
  • 7
  • 35
  • 51