skip to content

In SwiftUI, when do you choose fullScreenCover or popover over a sheet, and how does a popover behave on iPhone?

level: middleimportance: should knowfreq 35%

answer

  1. takeover versus anchored bubble
  2. compact size classes adapt
  3. a cover needs its own exit
  4. presentationCompactAdaptation since iOS 16.4

basics

~20 s

Use fullScreenCover for a takeover task and give it a Close button; use popover for small content anchored to a control on iPad or Mac. On iPhone a popover adapts into a sheet unless presentationCompactAdaptation says otherwise.

solid answer

~40 s

`fullScreenCover(isPresented:onDismiss:content:)` (iOS 14, not on macOS) covers as much of the screen as possible, which suits a photo capture or a media player; it has no drag-down gesture, so the content supplies a button that calls `dismiss()`. `popover(isPresented:attachmentAnchor:arrowEdge:content:)` anchors content to the view it modifies, which suits quick info from a toolbar button on iPad; a tap outside dismisses it. Popovers adapt: Apple's documentation says that on iPhone a popover appears as a sheet, and in a vertically compact environment such as iPhone landscape, sheets and popovers appear as full-screen covers. From iOS 16.4, `presentationCompactAdaptation(_:)` or `presentationCompactAdaptation(horizontal:vertical:)`, applied inside the presented content with values like `.popover`, `.sheet`, `.fullScreenCover` or `.none`, overrides that choice.

code

swift · 22 lines
swift
struct ContactPhotoButton: View {
    @State private var isCapturing = false

    var body: some View {
        Button("Take Photo") { isCapturing = true }
            .fullScreenCover(isPresented: $isCapturing) {
                CaptureScreen()
            }
    }
}

struct CaptureScreen: View {
    @Environment(\.dismiss) private var dismiss

    var body: some View {
        ZStack(alignment: .topTrailing) {
            Color.black.ignoresSafeArea()
            Button("Close") { dismiss() }
                .padding()
        }
    }
}

go deeper

for a junior

Recall the three containers: sheet for a card, fullScreenCover for a takeover with its own Close button, and popover for small content anchored to a control.

for a middle

Explain the compact adaptations the documentation states: popovers become sheets on iPhone, sheets and popovers become covers in vertically compact space, and presentationCompactAdaptation overrides both.

for a senior

Show you test each presentation in every size class and orientation, give covers an exit, and choose iPhone behaviour for popovers on purpose rather than by default.

for a principal

Set a team guideline for which container each kind of task uses, so presentations stay consistent across iPhone, iPad and Mac targets.

## Same pattern, different containers Sheets, full-screen covers and popovers share one shape in SwiftUI: a modifier on a view, an `isPresented:` Bool binding or an `item:` optional binding, and a content closure. What differs is how much of the screen they take, how people dismiss them, and how they **adapt** when space is tight. | | Sheet | Full-screen cover | Popover | |---|---|---|---| | Modifier | `sheet(isPresented:…)` | `fullScreenCover(isPresented:…)` | `popover(isPresented:…)` | | Since | iOS 13 | iOS 14, unavailable on macOS | iOS 13, unavailable on tvOS and watchOS | | Covers | a card, presenter visible behind it | as much of the screen as possible | a bubble anchored to a view | | Interactive dismissal | drag down | none | tap outside | | Fits | forms, previews, pickers | camera, media, immersive tasks | quick info and small controls on iPad and Mac | ## fullScreenCover: a takeover with its own exit `fullScreenCover(isPresented:onDismiss:content:)` and `fullScreenCover(item:onDismiss:content:)` present a modal view that covers as much of the screen as possible. The presenter disappears from view, which is the point for a camera capture or a video player in a contacts app. Because a cover does not offer the sheet's drag-down gesture, the content must provide a way out: - a Close or Done button that calls the `dismiss` action read inside the cover's own view, or - a tap or button that sets the presentation Bool back to `false`, as Apple's own example does. Forgetting this is the classic cover bug: a screen with no exit. ## popover: anchored, transient content `popover(isPresented:attachmentAnchor:arrowEdge:content:)` anchors its content to the view the modifier is attached to. - `attachmentAnchor` defaults to `.rect(.bounds)`, the whole frame of that view. - `arrowEdge` is an optional `Edge`; in the current SDK it defaults to `nil`, which lets the system choose the arrow edge. The documentation notes that before iOS 18.1 the arrow edge was not respected on iOS. - A tap outside the popover dismisses it; `interactiveDismissDisabled(_:)` can prevent that. ## Adaptation in compact size classes Size classes decide how the system renders a presentation. Apple's documentation states the defaults: 1. On iPhone, popovers adapt into **sheets**; more precisely, a popover over a horizontally compact view uses a sheet appearance. 2. In a vertically compact environment, such as iPhone in landscape, both sheets and popovers adapt to appear as **full-screen covers**. 3. From iOS 16.4, `presentationCompactAdaptation(_:)` sets one preference for both dimensions, and `presentationCompactAdaptation(horizontal:vertical:)` sets them separately; when a size class is compact in both dimensions, SwiftUI uses the vertical value. The values come from `PresentationAdaptation`: `.automatic`, `.none`, `.popover`, `.sheet` and `.fullScreenCover`. Like the detent modifiers, the adaptation modifier goes **inside** the presented content: ```swift Button("Info") { showsInfo = true } .popover(isPresented: $showsInfo) { Text("Last contacted 3 days ago") .padding() .presentationCompactAdaptation(.popover) } ``` With `.popover`, an iPhone shows a real anchored bubble instead of a sheet, which suits a one-line hint but not a form. ## Choosing between them - **The presenter should stay visible, or the content is a form**: a sheet, with detents if a partial height helps. - **The content is small and belongs to one control on a big screen**: a popover, then decide deliberately what iPhone shows (accept the sheet, or request `.popover`). - **The task replaces the screen** (capture, playback, a step that must not be swiped away by accident): a full-screen cover with an explicit exit. - **The person should confirm or acknowledge something short**: not any of these, but an alert or confirmation dialog. On iPad the horizontal size class can change while the app runs, for example in Split View or a resized window, so the same popover can switch to its compact adaptation mid-session. Test presentations at both widths, not only on the device you develop on. ## Mistakes that show up in review - A popover designed only on iPad that turns into a cramped sheet on iPhone, because nobody checked compact behaviour. - A full-screen cover with no Close button. - `presentationCompactAdaptation` attached to the presenter instead of the presented content. - Reaching for `fullScreenCover` on macOS, where the modifier is unavailable. Transitions such as zoom transitions from a source view are a separate topic, covered with SwiftUI's hero and zoom effects.

  • How would you keep a sheet looking like a sheet on an iPhone in landscape?
    Apply `presentationCompactAdaptation(.none)` inside the sheet's content, available from iOS 16.4. Apple's documentation shows exactly this to request that the system not adapt the sheet in compact size classes; otherwise a sheet in a vertically compact environment appears as a full-screen cover.
  • Can you stop a person from dismissing a popover by tapping outside it?
    Yes. `interactiveDismissDisabled(_:)` (iOS 15) prevents interactive dismissal of popovers and sheets, which for a popover means the tap outside. It does not block programmatic dismissal through the binding or `dismiss`. On macOS the documentation notes it makes the popover nontransient.

  • A popover on iPhone always shows as an anchored bubble with an arrow.
  • A full-screen cover can be swiped down like a sheet, so no Close button is needed.
  • fullScreenCover is available on every Apple platform, including macOS.
  • presentationCompactAdaptation goes on the button that triggers the popover.
  • popover is iPad-only and does nothing on iPhone.