Swift and SwiftUI tutorials for Swift Developers

How to present a Full Screen modal view with .fullScreenCover in SwiftUI

Since iOS 13 a modal view does not cover the entire screen by default. If you want to display a full-screen modal view you can use the .fullScreenCover modifier introduced with iOS 14.

Instead of using .sheet to display a modal view, you can use the .fullScreenCover modifier as follows:

struct ContentView: View {
    @State private var isPresented = false

    var body: some View {
        Button("Present!") {
            isPresented.toggle()
        }
        .fullScreenCover(isPresented: $isPresented, content: FullScreenModalView.init)
    }
}
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Article

How to create a Floating Button in SwiftUI

Next Article

How to create a Form in SwiftUI

Related Posts