Skip to content

Instantly share code, notes, and snippets.

@andresr-dev
Created April 25, 2022 17:52
Show Gist options
  • Save andresr-dev/0ed2b5504b80eaf2501c446d34fad566 to your computer and use it in GitHub Desktop.
Save andresr-dev/0ed2b5504b80eaf2501c446d34fad566 to your computer and use it in GitHub Desktop.
This is how you can add simple haptics to your applications.
import SwiftUI
struct SimpleHaptics: View {
var body: some View {
Text("Hello, World!")
.onTapGesture {
simpleSuccess()
}
}
func simpleSuccess() {
let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(.success)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment