Structure

TapGesture

A gesture that recognizes one or more taps. あるジェスチャ、それは1つ以上のタップを認識します。

Declaration 宣言

struct TapGesture

Overview 概要

To recognize a tap gesture on a view, create and configure the gesture, and then add it to the view using the gesture(_:including:) modifier. The following code adds a tap gesture to a Circle that toggles the color of the circle.


struct TapGestureView: View {
    @State 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)
    }
}

Topics 話題

Creating a Tap Gesture タップゼスチャを作成する

Supporting Types 支援を行う型

Default Implementations 省略時実装

Relationships 関係

Conforms To 次に準拠

See Also 参照

Basic Gestures 基本ジェスチャ