With the .edgesIgnoringSafeArea(.all)
you can ignore all safe area, but is there also something like .none so you can switch between the two via something like .edgesIgnoringSafeArea(isFullscreen ? .all : .none)
? Or how would you achieve this effect?
Asked
Active
Viewed 514 times
1 Answers
3
Yes, this can be easily done. Here is some example code:
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.
} }
-
This doesn't seem to work as a "real" `.none` since it doesn't reverse `.edgesIgnoringSafeArea(:)` from superviews ... In this example it probably just says "ignore nothing" but not explicitly "ignore none and undo previeous ignores", which is what I am trying to achieve. Any Ideas? :) – smat88dd Oct 10 '20 at 04:44
-
This was helpful for me: https://stackoverflow.com/a/61432382/3078330 – smat88dd Oct 10 '20 at 04:53