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

Weird behaviour of StackView with a label, image view and button inside it

I've a stack view with label, image view and button inside it. This stack view is configured for vertical axis with distribution and alignment set to fill. The label is not aligning to centre of the view as the button does. Why is this weird…
Sachin
  • 13
  • 4
1
vote
1 answer

Issues with dynamic height UIStackView using autolayout

I am trying to create a horizontal axis UIStackView with 2 views, a label and an image, that would look something like this: Blue is the label Image is the image The frame of the UIStackView is the green portion + the blue portion + image What…
Shawn Frank
  • 4,381
  • 2
  • 19
  • 29
1
vote
3 answers

UILabel not clickable in stack view programmatically created Swift

My question and code is based on this answer to one of my previous questions. I have programmatically created stackview where several labels are stored and I'm trying to make these labels clickable. I tried two different solutions: Make clickable…
Andrew
  • 1,947
  • 2
  • 23
  • 61
1
vote
1 answer

how can I make the the view show all my table view data while having it inside a view inside a scroll View

I have scroll view inside it I have a stack view inside it there is multiple views and a table view. when I run my app the table view can't be shown completely like only the first few rows can be shown like shown in the below photos: also if I try…
1
vote
2 answers

How should I set constraints to the subviews of my tableHeaderView?

I have this viewController: class CreateSkillGroupViewController: UIViewController { lazy var headerStack: UIStackView = { let stack = UIStackView(frame: CGRect(x: 0, y: 0, width: 20, height: 400)) stack.axis = .vertical …
BigBoy1337
  • 4,735
  • 16
  • 70
  • 138
1
vote
2 answers

UIScrollView not showing inside UIStackView

I have one UIStackView that stacks vertically two horizontal UIStackViews. That worked just fine. But the first sub-UIStackView had too many elements so I decided to wrap it inside a scrollView. The problem is that when I do so, this first sub-view…
Josemafuen
  • 682
  • 2
  • 16
  • 41
1
vote
1 answer

Prevent cell content from "jumping" when applying constraint

I have a subclassed UICollectionViewCell and I want it to expand when tapped. To achieve this, I put the title into a view ("titleStack") and the body into a separate view ("bodyStack"), and then put both of them into a container UIStackView…
1
vote
1 answer

How to fix an off-centered stack view?

Here I have a horizontal stack view with three subviews, however, it looks to be a bit off-centered as shown below. I tried to: Constrain the stack view's centerXAnchor to be equal to the superview's centerXAnchor Set the stack view's alignment to…
1
vote
0 answers

How to resize uilabel inside stackview?

I have uilabel call "sklabel" inside stackview like image below. But sklabel width size is following stavkview size. How to make it's width follow text width? Should i make something like Stackview -> uiview -> uilabel ?
lauwis
  • 323
  • 1
  • 4
  • 15
1
vote
1 answer

Make Image view in square while adding in vertical stack

I am trying to add image view in vertical stack view but also at the same time I want to have it in square i.e. it should be equal in width and height. Any help on how can I make this imageview square? reference pic attached here. Stack view consist…
iAsh
  • 447
  • 6
  • 19
1
vote
3 answers

StackView -Swap Buttons in ArrangedSubviews

I have a UIStackView initially set with 4 buttons. If I need to later swap out the last button with a new button or back to the initial button, how can I do that? lazy var stackView: UIStackView = { let sv = UIStackView() sv.axis =…
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
1
vote
1 answer

Image view crush stackview constraints in swift?

I have some issue about my stackview contraints or imageview constraints ı dont know actually.Probably both . This is my stackview constraints stackViewConst and this my imageview constraints imaviewConstraints . When ı try to run ı expect…
Sait47
  • 43
  • 6
1
vote
1 answer

Why my 2D UIViews don't appear on screen?

I'm trying to make UIView that contains 12x7 UIViews with margins. I thought that the best way gonna be make 7 Vertical Stacks and then add all them on one big Horizontal stack. And I coded it, but problem is that this Horizontal Stacks doesn't…
1
vote
1 answer

Swift 5 - why does my collectionview disappear when embedded in a stackview?

I am trying to make an Amazon clone. I am working on the products details page. basically you search, you click the tableviewcell for the item you want and you land on the details page. everything loads except for the collectionview which contains…
1
vote
1 answer

.equalSpacing in UIStackView not working properly with CustomView

I have created a custom view of checkbox / radio button that animates when checked and unchecked. Problem is when I embed the custom view to a stackView that is .equalSpacing the button cannot be tapped anymore, my guess is the borderView(which has…
Dreiohc
  • 317
  • 2
  • 12