【发布时间】:2020-10-17 00:10:15
【问题描述】:
使用.tabViewStyle(PageTabViewStyle()) 将 TabView 用作页面查看器可以正常工作,但尝试通过应用 edgesIgnoringSafeArea 让它从边缘运行到边缘似乎不起作用。
我在这里错过了什么?
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)
}
}
将另一个 .edgesIgnoringSafeArea(.all) 添加到Rectangle 或ForEach 也不起作用。
请注意,所有这些问题都是不同的,因为它们不使用 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
他们的解决方案(添加edgesIgnoringSafeArea(.all))在这种情况下不起作用。
【问题讨论】:
-
适用于 Xcode 12.2 beta 3