TechnologiesSwiftUIDocuments

DocumentLaunchGeometryProxy struct

iOSmacOStvOSwatchOSvisionOS✓ renders

A proxy for access to the frame of the scene and its title view.

How it works

DocumentLaunchGeometryProxy gives an accessory view the geometry of the surrounding document launch experience, so you can position custom content relative to the system-drawn launch elements without guessing at coordinates. SwiftUI hands you the proxy inside a DocumentLaunchView's accessory closure, after it has measured and laid out the title and its launch chrome. Reach for it when you want a label, badge, or call-to-action that stays anchored to the launch view's title even as its size or placement shifts across devices and orientations. Because the proxy reports live layout values rather than fixed points, your overlay tracks the launch view instead of drifting away from it.

  1. Receive the proxy from the accessory closure

    A DocumentLaunchGeometryProxy isn't constructed directly; you obtain it as the parameter SwiftUI passes into a document launch accessory builder. Here the overlayAccessoryView closure of DocumentLaunchView is declared { geometry in ... }, where geometry is the DocumentLaunchGeometryProxy for that launch view's current layout.

  2. Read titleViewFrame for the launch title's bounds

    The proxy exposes the resolved frame of the launch view's title as a rectangle, letting you anchor content to where the title actually sits. The example reads geometry.titleViewFrame and pulls .midX and .maxY from it to compute an x/y point just beneath the title.

  3. Drive a position() from the proxy's geometry

    Feeding the proxy's coordinates into a layout modifier is what turns the geometry into placement. The Text("Tap to begin") overlay is pinned with .position(x:y:) using geometry.titleViewFrame.midX for horizontal centering and geometry.titleViewFrame.maxY + 24 to offset it below the title, so the label follows the title wherever SwiftUI puts it.

  4. Keep the overlay decorative and reactive

    Content placed with the proxy is an overlay accessory: it draws above the launch view's background (the LinearGradient) and content (ContentUnavailableView) without participating in their layout. Because titleViewFrame is recomputed when the launch view re-lays out, the styled Text re-positions automatically rather than holding a stale point.

Try it — Change the y offset in .position from geometry.titleViewFrame.maxY + 24 to geometry.titleViewFrame.minY - 24 to move the "Tap to begin" label above the title, confirming the overlay tracks the proxy's reported frame edges.

Example & preview

Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.

DocumentLaunchGeometryProxy.swift
struct DocumentLaunchGeometryProxyDemo: View {
    var body: some View {
        DocumentLaunchView("Untitled") {
            ContentUnavailableView("No Document", systemImage: "doc")
        } background: {
            LinearGradient(
                colors: [.blue, .purple],
                startPoint: .top,
                endPoint: .bottom
            )
        } overlayAccessoryView: { geometry in
            // geometry is a DocumentLaunchGeometryProxy
            Text("Tap to begin")
                .font(.headline)
                .foregroundStyle(.white)
                .position(
                    x: geometry.titleViewFrame.midX,
                    y: geometry.titleViewFrame.maxY + 24
                )
        }
        .padding()
    }
}
Live preview
No Document
No Document
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →