使用.edgesIgnoringSafeArea(.all)
可以忽略所有安全区域,但是还有诸如.none之类的东西,以便您可以通过诸如.edgesIgnoringSafeArea(isFullscreen ? .all : .none)
之类在两者之间切换吗?或者您将如何实现这种效果?
答案 0 :(得分:2)
是的,这很容易做到。这是一些示例代码:
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.
} }