Home > Net >  Why is there a Gap between VStacks in SwiftUI?
Why is there a Gap between VStacks in SwiftUI?

Time:04-28

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 between?

struct TabbarView: View {    
var body: some View {        
    VStack{
        Spacer()   
            ZStack{
                Color.orange.opacity(0.5)
                VStack(spacing: 0){
                    Text("Home")
                        .padding()
                }
            }            
        Spacer()            
        HStack{
            VStack{
                Image(systemName: "homekit")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                    .frame(width: UIScreen.main.bounds.size.width / 15, height: UIScreen.main.bounds.size.height / 25)
            }
        }
        .frame(width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height / 13)
        .background(Color.purple)            
    }
    .ignoresSafeArea()      
   // .background(Color.purple.shadow(radius: 2))
}

}

enter image description here

  • Related