One Logo Pool Ball
SwiftUI · IOS API REFERENCE

SpatialTapGesture

struct · iOS 16.0+ · SDK 27.1

nonisolated struct SpatialTapGesture

A gesture that recognizes one or more taps and reports their location. To recognize a tap gesture on a view, create and configure the gesture, and then add it to the view using the ``View/gesture(_:including:)`` modifier. The following code adds a tap gesture to a ``Circle`` that toggles the color of the circle based on the tap location: struct TapGestureView: View { @State private var location: CGPoint = .zero var tap: some Gesture { SpatialTapGesture() .onEnded { event in self.location = event.location } } var body: some View { Circle() .fill(self.location.y > 50 ? Color.blue : Color.red) .frame(width: 100, height: 100, alignment: .center) .gesture(tap) } }

Members (5)

get · iOS 16.0+

coordinateSpace

TypeScript
get coordinateSpace(): _SwiftUICore_CoordinateSpace
Swift declaration
var coordinateSpace: CoordinateSpace

The coordinate space in which to receive location values.

set · iOS 16.0+

coordinateSpace

TypeScript
set coordinateSpace(value: _SwiftUICore_CoordinateSpace)
Swift declaration
var coordinateSpace: CoordinateSpace

The coordinate space in which to receive location values.

init · iOS 16.0+ · Deprecated in iOS 100000.0

init

TypeScript
static init(count?: number, coordinateSpace?: _SwiftUICore_CoordinateSpace): SpatialTapGesture
Swift declaration
nonisolated init(count: Int = 1, coordinateSpace: CoordinateSpace = .local)

Creates a tap gesture with the number of required taps and the coordinate space of the gesture's location. - Parameters: - count: The required number of taps to complete the tap gesture. - coordinateSpace: The coordinate space of the tap gesture's location.

get · iOS 16.0+

count

TypeScript
get count(): number
Swift declaration
var count: Int

The required number of tap events.

set · iOS 16.0+

count

TypeScript
set count(value: number)
Swift declaration
var count: Int

The required number of tap events.

Skipped declarations

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

SpatialTapGesture.init(count:coordinateSpace:)

This parameter hides a concrete Swift type.

SpatialTapGesture.init(count:coordinateSpace:inputKinds:)

This parameter hides a concrete Swift type.

All SwiftUI types →