Swift & SwiftUI
  • İçerikler
  • UI Bileşenleri
    • Text
    • Button
    • Image
    • Picker
    • SecureField
    • Stepper
    • Slider
    • TabView
    • Sheet
    • Action Sheet
    • Alert
  • Layout
    • Fill-Space-Equally
  • State & Data Flow
    • Content
    • EnvironmentObject
    • ObservableObject
    • ObservedObject
    • Binding
  • Gestures
    • TapGesture
    • DragGesture
    • MagnificationGesture
    • RotationGesture
    • LongPressGesture
    • Notes
  • Extra
    • GeometryReader
    • Timer
    • AlignmentGuide
    • PreferenceKey
  • Concurrency
    • Perform asynchronous operation
Powered by GitBook
On this page

Was this helpful?

  1. Gestures

TapGesture

Tappable Views (Image, Text, Anything)

Usage

Rectangle()
    .foregroundColor(.orange)
    .frame(width: 100, height: 100)
    .gesture(
        TapGesture(count: 1).onEnded {
            // Action
        }
    )
    
// Much easier one,
// we can use .onTapGesture directly on a view
Rectangle()
    .foregroundColor(.orange)
    .frame(width: 100, height: 100)
    .onTapGesture {
        // Action    
    }

TapGesture is usable for every View

PreviousBindingNextDragGesture

Last updated 5 years ago

Was this helpful?