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

StackView in stackView does not work with its spacing by swift

In UITableViewCell, I create a vertical stackView. I add horizontal stackView in the vertical stackView(consists of one UILabel(A) and UIImageView) and a UILabel(B). I set the spacing is 6 points to all stackViews. But if the width of UILabel(B) is…
kimpro
  • 107
  • 1
  • 2
  • 11
2
votes
1 answer

Auto shrink UILabel when other UILabel grows

I have a few labels, which should never be touching each other. See the image below (ignore the yellow letters): These are 4 labels in total, 2 player names and 2 scores. The name of the player will replace the original player label text. So…
Petravd1994
  • 893
  • 1
  • 8
  • 24
2
votes
1 answer

Using uistackviews in uitableviewcell

I'm trying to use a stackview inside a tableview cell. My stack view has two labels aligned horizontally. I've added a size class override in IB to align the labels vertically for compact width. The alignment of the label does change as expected but…
Phantom59
  • 947
  • 1
  • 8
  • 19
2
votes
0 answers

Xcode: minimum font size ignored on label under stack view

I'm trying to build a layout that can work on every size of iPhone (portrait only) and I'm using Stack views. Now, I was able to create a good layout using multiple stack views but I've found a problem with a UILabel: On my layout there are several…
Eduardo
  • 63
  • 7
2
votes
3 answers

iOS - How to position an unknown amount of SubViews with different Sizes horizontally centered.

I'm stuck with a problem I'm sure one of you guys can help me with. I'm developing an iOS-Application with Swift3 and what I'm trying to create is something like this: Screenshot1 Screenshot2 The screenshots show just a part of my…
2
votes
1 answer

Get the first UIButton in a UIStackView

I'm working on my view and I'm having an issue with getting a shadow around a button within the stack view. Most of the work I have done has been within the storyboard directly. Here is the method I am using to apply the shadow to the view func…
Bob R.
  • 21
  • 3
2
votes
2 answers

Cell with stackview not expanding when unhiding part of stackview

I have a viewcontroller with a tableview that's with rowHeight property set to UITableViewAutomaticDimension: class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { private var items: [String] = [] @IBOutlet…
Bart van Kuik
  • 4,704
  • 1
  • 33
  • 57
2
votes
3 answers

UIStackView's constraints break when spacing is set

XCode is throwing up the following constraint error when I attempt to use a UIStackView: ( "", "
sdasdadas
  • 23,917
  • 20
  • 63
  • 148
2
votes
1 answer

UIStackView not centering arrangedview

I am implementing a UIStackView and populating a UIStackView dynamically. But when there is a single view in UIStackView, the view is not centred in the UIStackView. I use horizontal axis, center alignment and fill equality distribution in…
AfterCoder
  • 731
  • 2
  • 6
  • 22
2
votes
2 answers

How to set dynamically spacing between elements in UIStackView?

How to with constrains set dynamically spacing between elements in UIStackView? If I'll try to set spacing in Attribute inspector with IPhone 7 device, I'll get something like this: But when I'll want to simulate it with IPhone 5 device, I'll get…
newca9h
  • 53
  • 2
  • 6
2
votes
0 answers

Replacing a UIView in a StackView does not replace the view but just changes the pointer to it?

I am working with UIStackViews and I encountered an interesting issue which I am not able to understand by myself. I think it is just a misunderstanding on my side in terms of memory management and addresses, but I would like a confirmation and a…
Marco Pappalardo
  • 935
  • 6
  • 23
2
votes
0 answers

How do i wrap UILabel text around UIButton text? *Swift*

Here is what I am trying to achieve. Instagram notification cell style: I have a UIButton, and 2 UILabels, each with separate styles. They are currently all individual, but I want them to look like one string. So no matter how many line breaks,…
Dan
  • 543
  • 2
  • 13
2
votes
3 answers

Tokens with close button

I'm trying to think of the best approach to get an interface like this: They are similar to the Stack Overflow tokens that you enter when asking a question, except I don't need to be able to type the tokens in, just add/remove them…
cannyboy
  • 24,180
  • 40
  • 146
  • 252
2
votes
1 answer

why the stack view's frame is (0.0, 0.0)?

I'm trying to autolayout my stack views and create its arrangedSubView(2 labels and 1 image) in code, but only one set of stack view is appear in simulator. When print the results in console, all labels and image have values, except all stack view's…
stephen
  • 519
  • 6
  • 22
2
votes
1 answer

addArrangedSubview and resizing the StackView

I'm trying to add view to a StackView with a button: import UIKit class ViewController: UIViewController { @IBOutlet weak var stackOutlet: UIStackView! @IBOutlet weak var buttonOutlet: UIButton! override func viewDidLoad() { …
petaire
  • 495
  • 1
  • 10
  • 23