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

Swift: how to center elements horizontally in vertical stackview

I have stackview with four elements that need to be centered horizontally: let stackView = UIStackView() stackView.axis = UILayoutConstraintAxis.vertical stackView.distribution = UIStackViewDistribution.equalSpacing stackView.alignment =…
Elena Rubilova
  • 367
  • 4
  • 16
1
vote
2 answers

UITableViewCell doesn't update height after adding a view to UIStackView

I have a UIStackView inside UITableViewCell's contentView. Based on user interaction, I add/remove items in the UIStackView. After modifying the items in UIStackView, I expect the cell to update it's height accordingly. But, it doesn't update it's…
iOS
  • 3,526
  • 3
  • 37
  • 82
1
vote
0 answers

Stack view invisible but working

I'm developping an application with Xamarin for iOS. I have a page that is filled with a UIStackView that I populate with an image and buttons. Everything works fine, despite the fact that nothing is visible, but if I click where the buttons should…
A. Silva
  • 629
  • 1
  • 6
  • 16
1
vote
2 answers

How to Animate Between Two Views Inside a StackView?

I would like to animate between two different UIView's that occupy the same space on the screen. Sometimes the user would like to see an Image and other times statistics. By tapping a button I would like to animate between the two. Right now I only…
aaronium112
  • 2,992
  • 4
  • 35
  • 50
1
vote
1 answer

iOS Swift 3 - UIButton on UIStackView in UICollectionViewCell is not responding to tap events (no interaction)

I have a UICollectionViewCell subclass which has a UIStackView on it. The StackView is populated with UIButtons and everything looks fine however the buttons are untappable. If I layout the same buttons on a UIScrollView (for the sake of…
Zigglzworth
  • 6,645
  • 9
  • 68
  • 107
1
vote
1 answer

iOS: What does gamut have to do with the axis of a UIStackView?

To add a trait variation for a certain size class on a stack view I am making, this Gamut attribute appears. What is it for and what it does do? How is it related to stack views?
user298519
  • 1,052
  • 1
  • 11
  • 27
1
vote
1 answer

fill a UIStackView programmatically

I have designed a UIStackView in a StoryBoard and I have added 2 UIbutton with a height contraint set at 70. My stackview is set to vertical fill and has some constraints set on the storyboard to fit in the Controller's View. I have added an outlet…
user3239711
  • 639
  • 1
  • 7
  • 24
1
vote
2 answers

How to avoid buttons dropping off bottom of screen and prevent text view from disappearing using autolayout - xcode/swift?

I am writing a simple iOS app in swift with xcode and have a navigation view in which I have a text view (to contain a sentence or two for a question) with two buttons below to go forward and back. I want the two buttons to fill the width of the…
laurie
  • 965
  • 1
  • 11
  • 21
1
vote
5 answers

Stackview arrange issue

I have a Horizontal StackView inside vertical StackView. Horizontal StackView contains a image (w=30 , h= 30) and a label. Need I need to make image & label to center horizontally as per label intrinsic content size. So, it looks like…
nirav
  • 573
  • 5
  • 20
1
vote
2 answers

Scale images of UIImage in UIStackView to fit screen size in iOS app

On my iOS app written in Swift 3, I have 4 UIImages, each 2 in a UIStackView, and the 2 UIStackViews inside another UIStackView, as shown in the picture below: In the picture you can see the division I made to the images. You can also see the…
Ido Naveh
  • 2,442
  • 3
  • 26
  • 57
1
vote
2 answers

Why is image view stretching to fill half the width in a UIStackView?

I am taking an UIImageView on the left of the horizontal stack view and a label with number of lines set to 0. The issue is that both the UIImageView and the label are filling equal space even though I have set the stack view distribution property…
1
vote
1 answer

UIStackView: control of spacing

I need to have X number of buttons in a horizontal UIStackView, which resides inside an UIScrollView. The requirement is that the buttons should be evenly distributed in the stack view, and as the number of buttons increases I should reduce the…
Heuristic
  • 5,087
  • 9
  • 54
  • 94
1
vote
1 answer

UIStoryBoard Auto Layout embed UIStackView inside UIScrollView

I'm having a problem design my ViewController which contain a some Label and a ImageView. I have embed them in a StackView. My objective is to place a StackView inside a ScrollView so that my content will be scrollable if the content is longer then…
Lê Khánh Vinh
  • 2,591
  • 5
  • 31
  • 77
1
vote
1 answer

UIStackView that responds gestures like UITableView

Question is simple, it is about adding gestures to horizontal stackView that has gestures like tableview. Think of horizontal tableView but also has certain stop points.(Avoiding view to stop any point.) To be more clear, A horizontal working…
Faruk
  • 2,269
  • 31
  • 42
1
vote
0 answers

Horizontal UIStackView Expanding Vertically

I've got a few nested UIStackViews as seen below: What I'm trying to achieve is, to have the bottom-right label expand and grow vertically as a multi-line UILabel. I've already set the following properties for it: Lines: 0 Line Break: Word…
Earthling
  • 283
  • 5
  • 17