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

Action not being called when button is tapped in a stack view

I have a custom view that includes a stack view. Inside the stack view I have a label and a button. I created my stack view, label and button in the following way and added them to the parent view. class HomeView: UIView { override init(frame:…
user2569905
  • 83
  • 1
  • 7
1
vote
2 answers

Multi Line Labels and an Image with UIStackView

I am trying to see if I can easily use a UIStackView to create multi line labels and also display an image. Here are my current constraints. When I run it I get the following: If I remove the imageview then the multi line works. Somehow…
john doe
  • 9,220
  • 23
  • 91
  • 167
1
vote
1 answer

How to make scrollview to pass touch event to the superview?

I am trying to create a UITableViewCell which has a horizontally scrollable UIScrollView. How to make sure that when user touches on the UIScrollView, the UITableViewCell gets selected. The UITableViewCell has a UIScrollView as a subview as well as…
user10461683
1
vote
1 answer

How to change the order of elements in stack view when changing axis in iOS?

I have a horizontal uistackview with these elements: stack view (horizontal) element1 | element 2 Then I change the axis programmatically. buttonsStackView.axis = UILayoutConstraintAxisVertical; Now the view is like this element1 …
Fattaneh Talebi
  • 727
  • 1
  • 16
  • 42
1
vote
1 answer

UIStackView in storyboard forces intrinsic content size

In storyboard I have added a UIStackView to a UIView and inside the UIStackView I've added a UIImageView with an image specified. The image specified is in XCAssets and has a 2X size of 59X60. The UIImageView is getting its width set to this…
bhartsb
  • 1,316
  • 14
  • 39
1
vote
2 answers

how to prevent buttons from shrinking in a stackview

I have been struggling with getting buttons (circular) to keep their size in a stack view to no avail.I have two rows of buttons where I place each row in its own horizontal stack view and then embed both stack views in an outer stack view to make…
Tim
  • 597
  • 8
  • 18
1
vote
2 answers

UIStackView unsatisfiable autolayout constraints

I have a UIStackView defined in storyboard with the first button's height set to 70 and other one set to 45. I get this autolayout error: [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
1
vote
1 answer

iOS layer masking doesn't work on UIStackView

I tried applying a layer mask in iOS (iOS12) on the layer of a UIStackView. The mask doesn't work and I still see the UIStackView whole.
ShayDavidson
  • 717
  • 1
  • 7
  • 20
1
vote
1 answer

UIStackview constraints not applied to edges on different iPhone screen size

i have a UITableView that contains a prototype cell holding labels , each label subbed in a view , all views stacked in a vertical UIStackView and i have a constrain for the stack ,, at runtime in iphone SE unless I set stack width for 414 ( for…
shahed
  • 21
  • 4
1
vote
1 answer

Axis change of stackView giving layout error

I have a UIStackView which is changing axis based on its width. It includes two UViews only. There is a very easy setup (can be copy/pasted to default Xcode project): class ViewController: UIViewController { enum DisplayMode { case…
Viktor Kucera
  • 6,177
  • 4
  • 32
  • 43
1
vote
3 answers

How to find index of selected item within a UIStackView Swift 4

I have 5 buttons within a UIStackView, and I want to find out which index is being selected, and later compare those indexes. My code right now gives me an Array.Index. I've tried both subviews and arrangedSubviews. Is there anyway I can turn this…
robinyapockets
  • 363
  • 5
  • 21
1
vote
2 answers

Constraints for Stack View in Stack View

Why is this happening? This is my constraints: Two stack views: horizontal and vertical, both distribution set on "Fill Equally". What am I doing wrong?
Hrvoje
  • 696
  • 7
  • 22
1
vote
1 answer

UIStackView Animation Issue

I have a subStackView inside a stackView and when I hide/show the contents of ONE subStackView, the animation goes all the way up over the other stack views: https://www.youtube.com/watch?v=vKXwX7OpkxU This is how I create the subStackView. I tried…
Martin Vidic
  • 763
  • 1
  • 6
  • 19
1
vote
1 answer

iOS 12, issue with UIStackView

I have used UIStackView to create chips which can be removed by the button of delete. It was working fine with iOS 11 as shown below But, I am facing an issue of overlapping of Tags in iOS 12 when I tried to remove the chip. The View removed from…
Mrug
  • 4,963
  • 2
  • 31
  • 53
1
vote
1 answer

iOS Stack view issue on iOS 10 and earlier

I've a table view cell with a label, text field and a stack view with two buttons in it. For the label, I've used a minimum font scale of 0.5 so that it can shrink text in iPhone SE and iPhone 5. The layout for iPhone 5s is as follows: The layout…