Horizontal Stack View New Row - Swift
Asked Answered
K

1

8

Stack Views's in iOS are a beautiful thing but I have realized there is no native way to create new rows in horizontal stack views. Let's say I dynamically added subviews in a horiztonal stack view and would want to create a new row once I reach an increment of 3 subviews respectively.

subview array stacked horizontally and vertically

Would I be required to create a vertical stack view then programmatically populate it with individual horizontal stack views at an interval of 3 increments?

If so, would swift support dynamic variable creation of horzStackView1, horzStackView2, ... ?

I'm starting to believe there is an easier way to implement this but I can't think of anything as I'm new to Swift 2.

Kaja answered 25/3, 2016 at 15:24 Comment(0)
W
6

Yes, you would have to manually setup the the vertical and horizontal stack views yourself.

You may want to look into using UICollectionView it supports having cells automatically wrap onto the next row if there is not enough space.

Whatever answered 25/3, 2016 at 15:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.