0

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

  • 1
    Did you try to add zero spacing `(VStack(spacing: 0))`? – Andrew Bogaevskyi Apr 26 '22 at 14:00
  • 2
    Welcome to Stack Overflow! Please take the [tour](https://stackoverflow.com/tour) and see: [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Reproducible Example (MRE)](https://stackoverflow.com/help/minimal-reproducible-example). Please post the actual code, not an image of it. We need to be able to copy and paste your code to debug. – Yrb Apr 26 '22 at 14:00
  • I tried zero spacing but doesn't work @AndrewBogaevskyi – Alican Kurt Apr 26 '22 at 15:32
  • FYI, that is still not an MRE. You need to post the `HomeView` which, at least, is the view that is not working. When you post the code, you should be able to take it, as is, copy and run it. As deleting the two `Spacer()` doesn't solve the problem, the problem could be in the actual views not shown, just referred to. – Yrb Apr 26 '22 at 19:08
  • I fixed the code and image in its simplest form. I apologize for using wrongly. – Alican Kurt Apr 27 '22 at 05:47

1 Answers1

0

you can add for VStack:

 VStack {}
            .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .center)

updated:

struct ContentView: View {
    var body: some View {
        ZStack {
            Color.orange.opacity(0.5)
            VStack {
                Spacer()
                VStack(spacing: 0){
                    Text("Home")
                        .padding()
                }
                Spacer()
                HStack {
                    VStack {
                        Image(systemName: "homekit")
                            .resizable()
                            .aspectRatio(contentMode: .fit)
                            .frame(width: 25, height: 25, alignment: .center)
                            .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()
        .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
    }
}

you used nesting incorrectly and there is a native TabView for tabs

result: enter image description here

sergio_veliz
  • 149
  • 9