As you can see, there is a strange white space between my VStack (the blue area) and ZStack views (the gray area). I don't understand why and I want to get rid of it. I expected that it has something to do with spacing.
the problem on iphone 14 canvas
Here is my code:
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
TabView(selection: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Selection@*/.constant(1)/*@END_MENU_TOKEN@*/) {
VStack {
VStack(spacing: 0) {
Text("Remaining Budget")
Text("Rp 1.000.000")
.font(.title)
.padding(7)
Text("February 2023")
HStack() {
VStack(alignment: .leading) {
Text("Budget")
Text("Rp 1.500.000")
}
Spacer()
VStack(alignment: .leading) {
Text("Expense")
Text("Rp 1.500.000")
}
}
.padding(.top)
.font(.system(size: 14, weight: .bold))
}
.padding([.top, .leading, .trailing, .bottom])
.background(Rectangle()
.fill(.blue.gradient)
.ignoresSafeArea(edges: [.top, .bottom]))
.foregroundColor(.white)
.font(.custom("Avenir-Heavy", size: 20))
ZStack {
Color(.secondarySystemBackground)
}
}.tabItem {
Label("Home", systemImage: "house.fill")
}.tag(1)
Text("Tab Content 2").tabItem { Label("Category", systemImage: "square.split.2x2.fill")
}.tag(2)
Text("Tab Content 2").tabItem {
Image(systemName: "plus.square")
.scaledToFit()
}.tag(3)
Text("Tab Content 2").tabItem { Label("Charts", systemImage: "chart.bar.fill")
}.tag(4)
Text("Tab Content 2").tabItem { Label("Settings", systemImage: "gearshape.fill")
}.tag(5)
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
I've tried changing the spacing parameter like VStack(spacing: 0) but it won't work.