Activates the view as the source of a drag and drop operation.
SDKs
- macOS 10.15+
- Xcode 11.0+
Framework
- Swift
UI
Declaration
func onDrag(_ data: @escaping () -> NSItem Provider) -> some View
Parameters
data
A closure that returns a single
NSItem
that represents the draggable data from this view.Provider
Return Value
A view that activates this view as the source of a drag and drop operation, beginning with user gesture input.
Discussion
Applying the on
modifier adds the appropriate gestures for drag and drop to this view. When a drag operation begins, a rendering of this view is generated and used as the preview image.