使用 .edgesIgnoringSafeArea(.all)
您可以忽略所有安全区域,但是否也有类似 .none 的内容,以便您可以通过 .edgesIgnoringSafeArea(isFullscreen 之类的内容在两者之间切换? .all : .none)
?或者说如何实现这种效果?
最佳答案
是的,这很容易做到。这是一些示例代码:
struct ContentView: View {
@State var isFullscreen = false
var body: some View {
VStack {
Spacer()
Button(action: {
self.isFullscreen.toggle()
}) {
Text("Fullscreen")
}
}
.edgesIgnoringSafeArea(isFullscreen ? .all : .init()) // This is what you need.
} }
关于swiftui - 是否有edgesIgnoringSafeArea 无值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61331982/