Created
April 25, 2022 17:52
-
-
Save andresr-dev/0ed2b5504b80eaf2501c446d34fad566 to your computer and use it in GitHub Desktop.
This is how you can add simple haptics to your applications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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