A Swift UI view that arranges its children in a vertical line.
Questions tagged [vstack]
193 questions
0
votes
1 answer
Aligning horizontal views which are part of a VStack
I have been given the following design for a tabbar:
I'm pretty close to replicating it, here is how my implementation looks:
Where I am struggling however is the finer detail of the alignment of the icons. So here is my code for the…

DevB1
- 1,235
- 3
- 17
- 43
0
votes
1 answer
Why is there a Gap between VStacks in SwiftUI?
A whiteness is seen in the area drawn with the red line. If I change the background color of the most inclusive Vstack, that white area changes.
Deleting spacer() lines doesn't work.
Why is there a gap even though there is no space in…

Alican Kurt
- 13
- 2
0
votes
0 answers
Referencing variables in a separate HStack within the same struct
I am almost done with this view, but am stuck on the final Total Calories row at the bottom. I cannot make it sum the protein/carb/fat calorie numbers. I believe this is because they are defined and changed out of scope (in the other HStack), so I…

HarryC
- 1
- 1
0
votes
1 answer
SwiftUI - grid / table with column headings
I'm trying to achieve a design which essentially has the following layout:
So I need column headings for this table or grid view. The second column does not need a heading.
This seems like a job for a LazyVGrid or LazyHGrid, however I can't seem to…

DevB1
- 1,235
- 3
- 17
- 43
0
votes
1 answer
How to Stack elements from a 3D list in Python
I have two lists like these:
x = np.array([1,2,3,4,5])
y_all = [[2,3,5,4,6],
[3,2,4,3,5],
[4,5,4,3,4]]
And I need the output to be like this:
[(1, 2),
(2, 3),
(3, 5),
(4, 4),
(5, 6),
(1, 3),
(2, 2),
(4, 3),
(5, 5),
(1,…

Mamdud
- 63
- 5
0
votes
1 answer
SwiftUI: DatePicker can't be put in a VStack in Form
See this simple example. Putting DatePicker in VStack has weird layout issue and causes all the content in VStack to not show up (I'm using XCode 13.2 + iOS15.2).
struct ContentView: View {
@State var date: Date = Date()
var body: some…

rayx
- 1,329
- 10
- 23
0
votes
0 answers
SwiftUI - Building Grid Layouts swiftUI ios 13.x*
I am using SwiftUI and trying to achieve UI like this to support iOS 13.x*, where buttons can be placed dynamically in the grid based on the available space in right side of stack and button size. Any help would be appreciated.

Anupam Mishra
- 3,408
- 5
- 35
- 63
0
votes
2 answers
How do I center these images in a straight line inside my HStack in SwiftUI
So I have an HStack nested inside of a VStack inside of a ScrollView and I am trying to center the middle photos in a straight line. As you can see in the photo, the pictures are offset based on the size of the text label to the left. (The longer…

ethanbrimhall
- 3
- 1
0
votes
0 answers
Can't set correct height for 2 subviews in Stack
I try to build a view in SwiftUI with 2 views vertically arranged. i can not have the top view smaller than the bottom view.
import SwiftUI
struct SettingList: View {
@State var texte: String = "tttttttttttttttt"
var body: some View {
…

Ptit Xav
- 3,006
- 2
- 6
- 15
0
votes
1 answer
SwiftUI customButton / view alignement issue in HStack
I have a row of custom buttons displayed in a VStack and a HStack, strangely the 2 rows are not aligning - see the example for the best I could achieve.
I suspect that it is due to the different content (text or SFSymbol) but the buttons "look" the…

jat
- 183
- 3
- 14
0
votes
1 answer
SwiftUI: Arrange middle layer in ZStack dependent on top layer
I would like to implement a UI, which has
a background image, which is fullscreen and scales with the device size
a gradient above the background image and below the main UI, which is aligned bottom and it's size is dependent of the positioning of…

FrankZp
- 2,022
- 3
- 28
- 41
0
votes
2 answers
Divide empty space in HStack/VStack proportionally
I have a HStack with Spacers and a Text.
HStack {
Spacer()
Text("Some Text")
Spacer()
}
Now I want the first Spacer to take X% of the available space (excluding the space taken by Text) and the bottom to take the rest.
If I use Geometry…

Kunal Verma
- 562
- 4
- 15
0
votes
1 answer
Efficient way to load big heterogeneous dataset in a numpy array?
I have to load a dataset into a big array with p instances where each instance has 2 dimensions (n_i, m). The length of the first dimension n_i is variable.
My first approach was to pad all the instances to the max_len over the first dimension,…

Samuel Rodríguez
- 117
- 1
- 7
0
votes
0 answers
SwiftUI Where exactly to use Lazy Stacks for performance optimization?
A lot of sites online that demonstrate using a Lazy stack to load a lot of views use e.g. ForEach(1...100, id: \.self) { value in to demonstrate usage. But in a production app with complex views I can't really find any resources for where and how…

GarySabo
- 5,806
- 5
- 49
- 124
0
votes
1 answer
Why can't I stack my 2 arrays vertically using numpy vstack?
>>> Ne['State_1_spe_sum'].shape
(3, 1)
>>> Ne['State_1_inc'].shape
(63, 1)
>>> np.vstack((Ne['State_1_spe_sum'], Ne['State_1_inc']))
---------------------------------------------------------------------------
TypeError …

vlaaaaaddd
- 19
- 5