'SwiftUI TabView with PageTabViewStyle in Landscape on device with safeArea adding odd leading edge inset
I have a TabView with PageTabViewStyle and when my device is in landscape orientation, there is an odd inset on the leading edge. This is not there on devices without a safeArea and it is not there on any edge in portrait.
struct ContentView: View {
var body: some View {
TabView {
Color.red
.edgesIgnoringSafeArea(.all)
}
.tabViewStyle(PageTabViewStyle())
.edgesIgnoringSafeArea(.all)
}
}
Solution 1:[1]
If you want to have only the background in fullscreen try it like this:
var body: some View {
ZStack {
// Background ignoring safe area
LinearGradient(colors: [Color(hue: 0.106, saturation: 0.234, brightness: 0.922, opacity: 1.0), Color.white], startPoint: .top, endPoint: .bottom)
.edgesIgnoringSafeArea(.all)
// TabView
TabView() {
Onboarding1()
Onboarding2()
Onboarding3()
}
.tabViewStyle(PageTabViewStyle())
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Maddin82 |

