Last active
July 17, 2018 18:44
-
-
Save saoudrizwan/92605cc1807b78e308fa2e7e00ac9f96 to your computer and use it in GitHub Desktop.
Haptic feedback UINotificationFeedbackGenerator example for iOS 10
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 UIKit | |
| let notificationFeedbackGenerator = UINotificationFeedbackGenerator() | |
| // We can inform the feedback generator that it will likely receive events soon, | |
| // which basically 'wakes up' the device's taptic engine for a few seconds, | |
| // preparing it for use without any latency. You can call this function as many | |
| // times as you want. Good times to call this are when a gesture begins and right | |
| // after a haptic signal is played. | |
| notificationFeedbackGenerator.prepare() | |
| // Play the desired haptic signals | |
| notificationFeedbackGenerator.notificationOccurred(.success) | |
| notificationFeedbackGenerator.notificationOccurred(.warning) | |
| notificationFeedbackGenerator.notificationOccurred(.error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment