Present and Dismiss a sheet in SwiftUI

A sheet in iOS is a system provided view that appears modally on top of any other currently displayed view.
A sheet is by default empty, we need to provide it with custom views and content.

Instance method: .sheet(isPresented:onDismiss:content:)


isPresentedA binding to a Boolean value that determines whether to present the sheet that you create in the modifier’s content closure.

onDismissThe closure to execute when dismissing the sheet.

contentA closure that returns the content of the sheet.

Now, Call this SheetView() in the ContentView().

Sheet with full screen cover

Presents a modal view that covers as much of the screen as possible when a given condition is true.

If you want that a sheet should cover full screen then it’s pretty easy to do; instead of using the sheet(isPresented:content:) view modifier, simply use the fullScreenCover(isPresented:content:)



iOS Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store