Apple has enabled developers to exploit the new Taptic Engine in the iPhone 7 and iPhone 7 Plus utilizing UIFeedbackGenerator. This implies that when a user interacts with your application, press some button you can give them Haptic feedback.
Let’s separate a portion of these different classes that provided us.
Type Of Haptic Feedback
-
- UINotificationFeedbackGenerator
- UIImpactFeedbackGenerator
- UISelectionFeedbackGenerator
These all allow you to provide different types of feedback based on the action performed by the user.
-
UINotificationFeedbackGenerator
This allows you to feedback to the user in the different type of three events such “error” “Warning” “success”
let generator = UINotificationFeedbackGenerator()
generator.notificationOccurred(.success)
-
UIImpactFeedbackGenerator
This enables you to give “light”, “medium” or “heavy” taps dependent on the client’s activity and your choice.
let generator = UIImpactFeedbackGenerator(style: .medium)
generator.impactOccurred()
-
UISelectionFeedbackGenerator
This should be used when a user is changing their selection This can be found in the Reminders application while picking any item from the picker
let generator = UISelectionFeedbackGenerator()
generator.selectionChanged()