- Remove .edgesIgnoringSafeArea(.all) from the TabView
- Add frame to the TabView with screen width and height
- Wrap a TabView with ScrollView
- Add .edgesIgnoringSafeArea(.all) to the ScrollView
struct ContentView: View {
let colors: [Color] = [.red, .green, .blue]
var body: some View {
ScrollView {
TabView {
ForEach(0...2, id: .self) { index in
Rectangle()
.fill(colors[index])
}
}
.frame(
width: UIScreen.main.bounds.width ,
height: UIScreen.main.bounds.height
)
.tabViewStyle(PageTabViewStyle())
}
.edgesIgnoringSafeArea(.all)
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…