quickLookPreview(_:in:)
Presents a Quick Look preview of the URLs you provide.
Declaration
nonisolated func quickLookPreview<Items>(_ selection: Binding<Items.Element?>, in items: Items) -> some View where Items : RandomAccessCollection, Items.Element == URL
Parameters
- selection:
A Binding to an element that’s part of the items collection. This is the URL that you currently want to preview.
- items:
A collection of URLs to preview.
Return Value
A view that presents the preview of the contents of the URL.
Discussion
The Quick Look preview appears when you set the binding to a non-nil item. When you set the item back to nil, Quick Look dismisses the preview. If the value of the selection binding isn’t contained in the items collection, Quick Look treats it the same as a nil selection.
Quick Look updates the value of the selection binding to match the URL of the file the user is previewing. Upon dismissal by the user, Quick Look automatically sets the item binding to nil.