Skip to content

Instantly share code, notes, and snippets.

@avii-7
Created April 28, 2025 04:54
Show Gist options
  • Save avii-7/e28625b0aa9231646980371c9bf9992c to your computer and use it in GitHub Desktop.
Save avii-7/e28625b0aa9231646980371c9bf9992c to your computer and use it in GitHub Desktop.
Page Style TabView is not respecting ignoreSafeArea inside NavigationStack
/*
There is a bug in SwiftUI, some how ignoreSafeArea(.top) don't work when you add PageStyle TabView inside NavigationStack.
This bug is reproduceable in minimum iOS 16.6
Solution: Just add color to TabView.
*/
struct ContentView: View {
var body: some View {
myTabView
}
// MARK: - Faulty Code.
private var myTabView: some View {
NavigationStack {
TabView {
VStack {
Image(systemName: "tv")
.resizable()
.frame(maxWidth: .infinity)
.frame(height: 390)
.ignoresSafeArea(edges: .top)
Spacer(minLength: 0)
}
.ignoresSafeArea(edges: .top)
}
.background(.red) // <-------- Solution
.tabViewStyle(.page(indexDisplayMode: .never))
.edgesIgnoringSafeArea(edges: .top)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment