Mark
Mark

Reputation: 18214

Is there a edgesIgnoringSafeArea none value?

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?

Upvotes: 2

Views: 611

Answers (1)

Kuhlemann
Kuhlemann

Reputation: 3396

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

Upvotes: 3

Related Questions