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
1
vote
1 answer

Two dynamic Stackviews in Scrollview

Here is my view's hierarchy ScrollView -> View -> Stackview1 -> view1 -> view2 . . . -> Stackview1 -> view1 -> view2 . . . So here my stackview's height is generated…
PJR
  • 13,052
  • 13
  • 64
  • 104
1
vote
3 answers

UIStackView not changing the width

I have a UIStackView with UIImageViews that might be from 1 to 5. Each UIImageView has an image coming from an array (from previously downloaded and cached images) and I'd like to keep the UIImageViews stay in a perfect circle. I change the width…
Dani
  • 3,427
  • 3
  • 28
  • 54
1
vote
1 answer

Images not being rounded in UIStackView

I'm trying to round several images and add them in a stack view, for some reason it's not working. Basically, I have an array with all UIImage names and assign them to a UIImageView. When I try to make a circle out of the image, it's not working : …
Dani
  • 3,427
  • 3
  • 28
  • 54
1
vote
1 answer

Add trailing constraint between two views

I got stuck with a weird behaviour I added programmatically a trailing constraint between 'UISlider' and 'UILabel', it looks like this: NSLayoutConstraint *timeLabelTrailing = [NSLayoutConstraint …
dudi hisine
  • 129
  • 11
1
vote
1 answer

How do I use a UIStackView in a non filling vertical capacity?

I want to stack varying height UIViews (each built in xibs) beneath the other (with a width that simply expands to meet the container) and I'm finding this hard probably because I don't understand it. My situation is relatively simple. I have a…
The Senator
  • 5,181
  • 2
  • 34
  • 49
1
vote
1 answer

UIStackView with UILabel and UIButton behaving strange

Putting an UILabel and an UIButton to an UIStackView causes a bigger spacing, than is really necessary. I need the info button to be directly next to the label. Setting constraints or hugging priorities didn't help. It looks like this. Distribution…
Simon C.
  • 1,605
  • 14
  • 13
1
vote
2 answers

UIStackView can't set bottom constraint when using UINavigationController

I have UIView where a UIStackView is a subview. Normally it fills the UIView. However, when I embed the UIView in a UINavigationController the UIView and UIStackView no longer extend to the bottom of the screen. It seems that they are getting a…
bhartsb
  • 1,316
  • 14
  • 39
1
vote
0 answers

How to get the dynamic stack view height in Swift

I have a stackView in my project. There are 6 elements in the stackView which have different values for height. And a fix spacing value for the stackView and some of them have top constraint. Is it possible to calculate the whole stackView…
Fattaneh Talebi
  • 727
  • 1
  • 16
  • 42
1
vote
0 answers

Loading custom view from XIB always stays with same frame inside stack view

I made a custom UIView in a xib and loaded as : class func instanceFromNib() -> ExclusiveCollectionView { return UINib(nibName: "ExclusiveCollectionView", bundle: nil).instantiate(withOwner: nil, options: nil)[0] as!…
byJeevan
  • 3,728
  • 3
  • 37
  • 60
1
vote
1 answer

How to add UIImageViews to a UIStackView that is constrained to the centerXAnchor of a view?

I'm trying to add profile icons via UIImageViews to a UIStackView in order to keep the icons centered in a view. How would I go about adding UIImageViews of a fixed frame to a UIStackView and keep the UIStackView centered in the main view according…
Explorer
  • 65
  • 1
  • 12
1
vote
1 answer

How to Overlap subViews in a stackView?

I have a stackView that I fill as such: override func awakeFromNib() { super.awakeFromNib() for _ in 0 ..< 31 { let tick = UIView() self.dayTicks?.addArrangedSubview(tick) let arrowImage = UIImage(named: "Up Arrow") …
BigBoy1337
  • 4,735
  • 16
  • 70
  • 138
1
vote
1 answer

How to add a button to the side and in between UIStackView rows

Imagine a horizontal stack view that contains two controls. Hopefully the type of controls doesn’t matter. Let’s say UITextFields. They’re set to take up 50 percent of the width via distribute evenly on their parent stack view. Now imagine that I…
Ash
  • 44
  • 8
1
vote
2 answers

Implementing UIStackView inside UICollectionViewCell

I am trying to display user ratings on the collectionview as follows with using two images, half.png and full.png. But even though I hard coded with 1 star to test, but sometimes it shows more than 1 star during the scroll. It keeps increasing. I…
casillas
  • 16,351
  • 19
  • 115
  • 215
1
vote
1 answer

UIStackView and Fill Distribution - Not Honouring Content Hugging Priority

I have a ViewController with a UIStackView aligned to its parent container with some margins (Leading, Trailing, Top Space, Bottom) and Vertical Axis. UIStackView is set to Alignment "Fill" and Distribution "Equal Spacing". Inside the UIStackView,…
pwnell
  • 171
  • 1
  • 11
1
vote
1 answer

SubViews being duplicated across collectionView cells?

I have a collectionView that represents a span of time. Each cell is a month. In each cell there is a horizontal stack view where each view represents a day. The full project is here if you wanna try it out:…
BigBoy1337
  • 4,735
  • 16
  • 70
  • 138