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.
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
overlayAccessoryViewclosure ofDocumentLaunchViewis declared{ geometry in ... }, wheregeometryis the DocumentLaunchGeometryProxy for that launch view's current layout.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.titleViewFrameand pulls.midXand.maxYfrom it to compute an x/y point just beneath the title.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:)usinggeometry.titleViewFrame.midXfor horizontal centering andgeometry.titleViewFrame.maxY + 24to offset it below the title, so the label follows the title wherever SwiftUI puts it.Keep the overlay decorative and reactive
Content placed with the proxy is an overlay accessory: it draws above the launch view's
background(theLinearGradient) and content (ContentUnavailableView) without participating in their layout. BecausetitleViewFrameis recomputed when the launch view re-lays out, the styledTextre-positions automatically rather than holding a stale point.
.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.
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()
}
}