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
3
votes
3 answers

Ios show/hide views inside a tableview cell

I have a tableview with a custom cell. Below image shows the view hierarchy of my tableview cell. When adding rows to the tableview I'm hiding the 'check Image' imageview using below code. func tableView(_ tableView: UITableView, cellForRowAt…
udi
  • 303
  • 1
  • 6
  • 19
3
votes
2 answers

Define width of views inside a stack view?

I want to create a graph like design with the help of stackviews.I have added 5 view horizotally inside a stackview.Now what i wanted to do is give a single view some height sat 25 & make property of stack view as equal width but somehow i couldn't…
TechChain
  • 8,404
  • 29
  • 103
  • 228
3
votes
3 answers

Swift: Bring View from Stack View to front

I got a Stack View with view: 1,2,3,4 and 5 Looking for a method to bring the Image View4 from view4 in the Stack view, above all the other views. The reason I need this is because I am moving the Image View4 over the Image View3 in view3. I have…
Shift72
  • 426
  • 4
  • 21
3
votes
1 answer

UIStackView not resizing its width inside UIScrollView

I have to display multiple views inside a single view controller. I have added a scroll view and added the views through the interface builder. Constraints added to all four sides as well. Each label (green label) and view (gray view) is embedded…
Isuru
  • 30,617
  • 60
  • 187
  • 303
3
votes
3 answers

Resize Stack View

I have a UILabel and a Switch on storyboard, I use Stack View to group them, however,after embedded into a horizontal Stack View, I am not able to resize the stack view but only can move it around. Why? (I am using XCode 8 + Swift 3) ===== UPDATE…
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
3
votes
0 answers

UIView disappear after wrapped into a stack view

The view hierarchy is simple: Scroll view (UIScrollView) - Content View (UIView) - Stack View - Hello (UILabel) - White view (UIView) As shown below: As you see above, the Stack View consists of only two components the…
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
3
votes
3 answers

Adding Stackview to UIScrollView

I have a UIScrollView. It has a stack view. And this stack view contains 12 buttons. (Horizontal scroll view) Stackview constraints :- top,leading,trailing,bottom to the scroll view and equal widths to the scroll view. My problem is every time when…
user1960169
  • 3,533
  • 12
  • 39
  • 61
3
votes
1 answer

UILabel inside nested UIStackViews inside UITableViewCell sometimes truncating

I have a tableview cell in one of my tables setup as containing the following view hierarchy The outer horizontal stackview is pinned to the cell's content view on trailing, leading, bottom and top edges. The right label is pinned to its parent…
jimbobuk
  • 1,211
  • 12
  • 25
3
votes
1 answer

How to stack custom views inside a UIStackView

Note: I'm pretty new working with iOS UI. I want to create a custom view that stacks a custom view inside. So I created the custom UIStackView class CustomStackView: UIStackView { func addItem(color:UIColor){ let bundle = Bundle(for:…
Addev
  • 31,819
  • 51
  • 183
  • 302
3
votes
1 answer

UIStackView - Auto calculate ideal size based on children

While using a playground to play with UIStackView programmatically that contains two labels, I realized that the way I'm doing the stack view and the labels don't calculate their sizes automatically. That's my (ugly) code: import UIKit let label1 =…
llanfair
  • 1,845
  • 4
  • 27
  • 43
3
votes
2 answers

UIScrollView height while adding content programmatically in UIStackView

I am trying to make a view containing an UIScrollView. This UIScrollView contains 3 UIViews. The last one contains another UIStackView I wanted to fill at runtime. Here an image of the storyboard : But when I add content at runtime in the second…
Mory
  • 198
  • 9
3
votes
1 answer

AutoLayout and Embedded stackview constraint conflicts

hoping someone can point me in the right direction here. I have a layout I'm trying to build with a vertical stackview. Stackview is pinned at the left, top and right edges of view at 0. I have a horizontal stackview inside which has 3 images all…
James Scott
  • 990
  • 2
  • 10
  • 29
3
votes
1 answer

UITextfield gets cut from the top while in editing mode

I got two UITextfields with separator(UILabel) between them. I put them all into UIStackView. While in editing mode, content of the textfield is cut from the top, as seen in the picture below I've found that the only way to remove this issue is to…
theDC
  • 6,364
  • 10
  • 56
  • 98
3
votes
2 answers

UIStackview fill proportionally in a UITableviewCell takes incorrect frame

Adding proportional fill setting in a UIStackview won't let the view stretch properly. Is this the expected behaviour?
nr5
  • 4,228
  • 8
  • 42
  • 82
3
votes
2 answers

Put margin between elements in IOS stack view

I want a login screen that contain user name and password text field and a button. I add all this fields in a stack view and the margin between the components gone.How can I put margin between elements in IOS stack view?
Shanto George
  • 994
  • 13
  • 26