Using a TabView as a pageviewer by using .tabViewStyle(PageTabViewStyle())
works fine, but trying to let it run from edge to edge by applying edgesIgnoringSafeArea
does not seem to work.
What am I missing here?
struct ContentView: View {
let colors: [Color] = [.red, .green, .blue]
var body: some View {
TabView {
ForEach(0...2, id: \.self) { index in
Rectangle()
.fill(colors[index])
}
}
.tabViewStyle(PageTabViewStyle())
.edgesIgnoringSafeArea(.all)
}
}
Adding another .edgesIgnoringSafeArea(.all)
to the Rectangle
or ForEach
also doen't work.
Note that all these questions are different because they do not use use PageTabViewStyle()
:
- How do I use a TabView with a NavigationView in SwiftUI?
- Adding a TabView makes the Navigation Bar not cover the safe area in SwiftUI
- NavigationView doesn't display correctly when using TabView in SwiftUI
- In my NavigationView '.edgesIgnoringSafeArea' does not move content past the safe area
Their solution (adding edgesIgnoringSafeArea(.all)
) doesn't work in this case.