When adding a TabView in my SwiftUI iOS App, the Navigation Bar stops covering up the notch
I've tried creating another file for the TabView implementation ( Modifying SceneDeletage and so on)
Here is a simple code without TabView that makes the Navigation Bar cover the safe area (aka the notch)
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView{
ScrollView{
HStack{
VStack{
ForEach((1...10), id: \.self){_ in
Text("Hello")
.padding(.leading, 20)
}
}
Spacer()
//.padding(.leading, 20)
}
}
.navigationBarTitle("Title Covers Safe Area")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Here is a code with TabView that makes the Navigation Bar NOT cover up the safe area
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
NavigationView{
ScrollView{
HStack{
VStack{
ForEach((1...10), id: \.self){_ in
Text("Hello")
}
}
Spacer()
}
.padding(.leading, 20)
}
.navigationBarTitle("Doesn't Cover Safe Area")
}
.tabItem {
Image(systemName: "1.circle")
Text("First")
}.tag(0)
HStack{
Spacer()
VStack{
Spacer()
Text("Second View")
.font(.system(size: 40))
}
}
.tabItem {
Image(systemName: "2.circle")
Text("Second")
}.tag(1)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}