Haptic Feedback with Swift

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.


  1. UINotificationFeedbackGenerator

    This allows you to feedback to the user in the different type of three events such “error” “Warning” “success”

    let generator = UINotificationFeedbackGenerator()



  2. 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)



  3. 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()


Posted in iOS

Leave a Reply

Your email address will not be published. Required fields are marked *