Created
April 28, 2025 04:54
-
-
Save avii-7/e28625b0aa9231646980371c9bf9992c to your computer and use it in GitHub Desktop.
Page Style TabView is not respecting ignoreSafeArea inside NavigationStack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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