SwiftUI - Applying a Tap Gesture to an HStack

From PeformIQ Upgrade
Jump to navigation Jump to search

Implementing a Tap Gesture on an HStack

struct ContentView: View {
    var body: some View {
        HStack {
            Image(systemName: "square.fill")
            Text("Tap me...")
        }
        .contentShape(Rectangle())
        .onTapGesture {
            print("HStack tapped...")
        }

    }
}