タップイベントとアラートのサンプル。
import SwiftUI struct ContentView : View { @State var numberOfTaps = 12 @State var isZero = false var body: some View { let tap = TapGesture() .onEnded { _ in if self.numberOfTaps > 0 { self.numberOfTaps -= 1 } if self.numberOfTaps == 0 { self.isZero = true } } return ZStack { Circle() .fill(Color.blue) .frame(width: 200) .gesture(tap) .presentation($isZero){ Alert(title: Text("All done!"), message: nil, dismissButton: .default(Text("Yay!"))) } Text("\(numberOfTaps)\nTasks") .font(.largeTitle) .color(Color.white) .multilineTextAlignment(.center) .lineLimit(2) } } }