One Logo Pool Ball
SwiftUI · IOS API REFERENCE

DragGesture

struct · iOS 13.0+ · SDK 27.1

@MainActor @preconcurrency struct DragGesture

A dragging motion that invokes an action as the drag-event sequence changes. To recognize a drag gesture on a view, create and configure the gesture, and then add it to the view using the ``View/gesture(_:including:)`` modifier. Add a drag gesture to a ``Circle`` and change its color while the user performs the drag gesture: struct DragGestureView: View { @State private var isDragging = false var drag: some Gesture { DragGesture() .onChanged { _ in self.isDragging = true } .onEnded { _ in self.isDragging = false } } var body: some View { Circle() .fill(self.isDragging ? Color.red : Color.blue) .frame(width: 100, height: 100, alignment: .center) .gesture(drag) } }

Members (5)

get · iOS 13.0+

coordinateSpace

TypeScript
get coordinateSpace(): Promise<_SwiftUICore_CoordinateSpace>
Swift declaration
@MainActor @preconcurrency var coordinateSpace: CoordinateSpace

The coordinate space in which to receive location values.

set · iOS 13.0+

coordinateSpace

TypeScript
setCoordinateSpace(value: _SwiftUICore_CoordinateSpace): Promise<void>
Swift declaration
@MainActor @preconcurrency var coordinateSpace: CoordinateSpace

The coordinate space in which to receive location values.

get · iOS 13.0+

minimumDistance

TypeScript
get minimumDistance(): Promise<number>
Swift declaration
@MainActor @preconcurrency var minimumDistance: CGFloat

The minimum dragging distance before the gesture succeeds.

set · iOS 13.0+

minimumDistance

TypeScript
setMinimumDistance(value: number): Promise<void>
Swift declaration
@MainActor @preconcurrency var minimumDistance: CGFloat

The minimum dragging distance before the gesture succeeds.

init · iOS 13.0+ · Deprecated in iOS 100000.0

init

TypeScript
static init(minimumDistance?: number, coordinateSpace?: _SwiftUICore_CoordinateSpace): Promise<DragGesture>
Swift declaration
@MainActor @preconcurrency init(minimumDistance: CGFloat = 10, coordinateSpace: CoordinateSpace = .local)

Creates a dragging gesture with the minimum dragging distance before the gesture succeeds and the coordinate space of the gesture's location. - Parameters: - minimumDistance: The minimum dragging distance for the gesture to succeed. - coordinateSpace: The coordinate space of the dragging gesture's location.

Skipped declarations

2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

DragGesture.init(minimumDistance:coordinateSpace:)

This parameter hides a concrete Swift type.

DragGesture.init(minimumDistance:coordinateSpace:inputKinds:)

This parameter hides a concrete Swift type.

All SwiftUI types →