One Logo Pool Ball
SwiftUICore · IOS API REFERENCE

TapGesture

struct · iOS 13.0+ · SDK 27.1

nonisolated struct TapGesture

A gesture that recognizes one or more taps. 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: struct TapGestureView: View { @State private var tapped = false var tap: some Gesture { TapGesture(count: 1) .onEnded { _ in self.tapped = !self.tapped } } var body: some View { Circle() .fill(self.tapped ? Color.blue : Color.red) .frame(width: 100, height: 100, alignment: .center) .gesture(tap) } }

Members (4)

init · iOS 27.0+

init

TypeScript
static initCountInputKinds(count?: number, inputKinds?: GestureInputKinds): TapGesture
Swift declaration
nonisolated init(count: Int = 1, inputKinds: GestureInputKinds = .all)

Creates a tap gesture with the number of required taps and the input kinds the gesture recognizes. - Parameters: - count: The required number of taps to complete the tap gesture. - inputKinds: A set of input kinds that this gesture recognizes. If not specified, the gesture will recognize all applicable input kinds that a person can use to perform it.

init · iOS 13.0+

init

TypeScript
static initCount(count?: number): TapGesture
Swift declaration
nonisolated init(count: Int = 1)

Creates a tap gesture with the number of required taps. - Parameter count: The required number of taps to complete the tap gesture.

get · iOS 13.0+

count

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

The required number of tap events.

set · iOS 13.0+

count

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

The required number of tap events.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUICore types →