read

There is a new modifier in SwiftUI 2.0, announced in WWDC 2020, for iOS 14 (beta). But the API is actually back dated to iOS 13.

fullScreenCover

It works similarly to sheet, but full screen.

struct PresentFullScreen: View {
    @State var isPresentedFullScreen = false
    var body: some View {
        Button("Present Full Screen") {
            isPresentedFullScreen.toggle()
        }
        .fullScreenCover(isPresented: $isPresentedFullScreen) {
            Text("New Screen Presented")
            Button("Dismiss") {
                isPresentedFullScreen.toggle()
            }
        }
    }
}

Passing an Item

You could also pass an optional Item binding. Then when it is non-nil, the view will be displayed.

So if you have an item such as @State var book = Book(), you can pass that into fullScreenCover(item:), then you can use it in the presented view.

.fullScreenCover(item: $book) {
    BookView(book: $0)
}

Image

@samwize

¯\_(ツ)_/¯

Back to Home