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

Proportional stack view constraints throwing dozens of conflict

I am trying to setup a simple login view which consists of an image, text fields and buttons. I decided to use a stack view to make the storyboard compatible with many screens. Image of constraints I can see that there are dozens of problems with…
Rick G
  • 11
  • 1
-1
votes
3 answers

UIStackView Layout

I would like to have two UIButtons side by side in a UIStackView both at 50% of the view. When I drag two buttons into the Stack View, the first one takes up the majority of the view and the other is the smallest width it can be. Should I be doing…
Tom Coomer
  • 6,227
  • 12
  • 45
  • 82
-2
votes
1 answer

Content Hugging Priority With UIImageView

I am laying out a similar UIStackView to Twitter's author layout as per below; However, I am not getting the desired effect from setting the various priorities; setContentHuggingPriority(UILayoutPriority(rawValue: 1), for: .horizontal) The…
David Henry
  • 1,972
  • 20
  • 43
-2
votes
2 answers

What constraints/stack view settings are recommended when stacking label, image, text, buttons, and collection view

I am trying to use a vertical stack view (Stack View 1) to fill an entire screen where the elements in the stack are a horizontal stack view with 2 labels (Stack View2), an image view, a text View, a horizontal stack view with buttons to add content…
Daniel Patriarca
  • 361
  • 3
  • 20
-2
votes
1 answer

Programmatically emptying UIStackView

I have a fairly simple code which, upon clicking a button, adds a randomly colored UIView to a UIStackView, and upon a different button click, removes a random UIView from the UIStackView. Here's the code: import UIKit class ViewController:…
Idanis
  • 1,918
  • 6
  • 38
  • 69
-2
votes
3 answers

Is there any proper way to fill equally labels in stack view?

I need to layout my labels like this: But i'm getting this layout: If I add spaces between two labels, then they all move out: Here's view hierarchy:
Alexander
  • 163
  • 8
-2
votes
1 answer

Swift 5 - Layout errors

Why do I get errors like that shown in the image? I have a horizontal stack embedded in a vertical stack, and want a left and right margin for the label and text field of 50 points from the leading and trailing edges of the vertical stack it sits…
Kimbo
  • 7
  • 1
-2
votes
1 answer

Center an icon image which is inside image which is inside stackview

Hey guys i want to center an image inside an image which is inside stackview. let stackview = UIStackView() stackview.addArrangedSubview(imageview) imageview.addSubview(anotherimageview) I want anotherimageview centered which is an icon image.
swift dev
  • 5
  • 3
-2
votes
2 answers

Dynamically sized stackView for less content

I have custom XIB's which I will be using to create my ViewController at runtime. Which all XIB's are to be included inside the ViewController will be decided at runtime. I am using a stackView for that purpose which I have added to the storyboard…
user121095
  • 697
  • 2
  • 6
  • 18
-2
votes
2 answers

Want to resize Horizontal StackView that has CollectionView and a Button inside it

I am using a Horizontal CollectionView and UIButton embedded inside a Horizontal StackView. Button has a fixed Height and Width (say 50 X 50 )I want Stackview Width to be dynamic according to CollectionView contentsize. Please guide me through…
TMirza
  • 47
  • 5
-2
votes
2 answers

StackView subview constant widths

I am trying to add 7 x-axis values on a graph. I am trying to do this using a horizontal stackview with 7 labels inside of it, then programmatically setting each label's (subview's) contents. But I can't get these labels to stay in the right…
Greg
  • 667
  • 8
  • 19
-2
votes
2 answers

how to add separate selectors/listeners to each buttons in StackView programmatically swift 4.2

I've added buttons into uistackview programmatically with for loop but I want each button have it's own separate listeners and I can't think up a logic for it. I've tried to add a #selector but obviously they all call the same method. for…
Mumtaz Hussain
  • 925
  • 9
  • 23
-2
votes
1 answer

Setting constraints to UIStackview

I've recently started to use UIStackViews auto layout, but keep running into warnings like the ones on the screenshot and I'm not sure how to make them go away. image image2image3image4image5Any help would be appreciated. [1]:…
Aaron Owusu
  • 13
  • 1
  • 4
-2
votes
4 answers

How to access text value from textfield using objective c with tag?

Output imageActually i am new to objective c. My problem is how to fetch text from textfield with tag. Where textfields are located inside nested uistackview. So i am not able to get the value of text field from that nested uistackview. How it…
-2
votes
1 answer

Swift - Controlling what is displayed in a custom tableviewcell

I have a custom cell that has a stackview that contains several buttons. I need to be able to show each button depending on a data item. for example in one cell three buttons will appear, in another 4 different buttons appear, in another all…
lascoff
  • 1,321
  • 4
  • 17
  • 35
1 2 3
95
96