.edgesIgnoringSafeArea not working in tabbed view

Hi,


I'm relatively new to coding and am playing around with SwiftUI. Specifically I'm trying to follow Apple's tutorial (https://developer.apple.com/tutorials/swiftui/creating-and-combining-views) to get an understanding. I'm applying the tutorial to a tabbed view app, rather than a single view app. .edgesIgnoringSafeArea(.top) however, does not seem to be working. Is this a specific trait of a tabbed view app?


My code looks as following:


import SwiftUI

struct ContentView: View {
    @State private var selection = 0

    var body: some View {
        TabView(selection: $selection){
            VStack {
                MapView()
                    .edgesIgnoringSafeArea(.top)
                    .frame(height: 350)
                CircleView()
                    .offset(y:-130)
                    .padding(.bottom, -130)
                Text("Hello World")
                    .font(.title)
                Spacer()
            }
                .tabItem {
                    VStack {
                        Image("first")
                        Text("First")
                        }
                    }
                .tag(0)
            Text("Second View")
                .font(.title)
                .tabItem {
                    VStack {
                        Image("second")
                        Text("Second")
                    }
                }
                .tag(1)
            Text("Third View")
                .font(.title)
                .tabItem {
                    VStack {
                        Image("first")
                        Text("Third")
                    }
                }
                .tag(2)
            Text("Fourth View")
                .font(.title)
                .tabItem {
                    VStack {
                        Image("second")
                        Text("Fourth")
                    }
                }
                .tag(3)
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}


When running it the safe area is not being ignored. Am I missing something here?


Regards,


Vincent

Replies

Same thing here!


import SwiftUI

struct BudgetView: View {
    var body: some View {
        ZStack {
            
            Color("primary")
            .edgesIgnoringSafeArea(.all)

            VStack {
                HStack {
                    Text("Coming soon...")
                        .font(.largeTitle)
                        .fontWeight(.black)
                        .foregroundColor(Color(.white))
                }
            }
            
        }
    }
}

struct BudgetView_Previews: PreviewProvider {
    static var previews: some View {
        TabView {
            BudgetView()
        }
    }
}