How to use haptic feedback touch in SwiftUI?
Jul 20, 2021
I think this is the simplest way to implement haptic feedback sound in SwiftUI
Button(action: {
// most preferred.
UIImpactFeedbackGenerator(style: .soft).impactOccurred() //other styles -> .light, .medium, .heavy, .rigid
}) {
Text("My button title")
}
You can even integrate this on the gesture or anywhere on the SwiftUI action.