是否存在边缘忽略安全区域none值



使用.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.       
} }

最新更新