Haptic Feedback Generators

Haptic feedback provides a tactile response and reinforces actions and events.


Haptics are an important way to get the user’s attention. It provides feedback to users giving the sensation of an impact or motion trough a tactile response, like a tap on the screen.

Each haptic feedback is generated by the Taptic Engine. For instance, since iPhone 7 Taptic Engine was used to mimic a home button press trough a haptic feedback.

Feedback Generators Subclasses

There are 3 subclasses that Apple provides in order to generate the haptic feedback:

  • UIImpactFeedbackGenerator: Indicate that an impact has occurred. For example, you might trigger impact feedback when a user interface object collides with another object or snaps into place.
  • UINotificationFeedbackGenerator: Indicates that a task or action was a success or a failure or had a warning. For example, in a login network call or in “pull down to refresh”.
  • UISelectionFeedbackGenerator: Use selection feedback generators to indicate a change in selection. For example, the user feels light taps while scrolling a picker wheel or enable disable a switch.

Note: UIFeedbackGenerator is the abstract superclass for all feedback generators. Do not subclass or create instances of this class. Instead, instantiate one of the mentioned subclasses above.

Feedback Generators Tips

  • If you want to include sound along with the haptic feedback, you need to manually play the sound and sync it with the haptics.
  • Always use feedback for its intended purpose. Don’t select a haptic because of the way it feels.
  • The source of the feedback must be clear to the user. For example, the feedback must match a visual change in the user interface, or must be in response to a user action. Feedback should never come as a surprise.
  • Don’t overuse feedback. Overuse can cause confusion and diminish the feedback’s significance.

How to use Haptic Feedback Generators?

To use a feedback generator, the following are required:

  1. Instantiating the Generator
  2. Preparing the Generator (optional)
  3. Triggering Feedback
  4. Releasing the Generator (optional).

Note: Feedback Generators have a milliseconds latency period after its triggered. Preparing the generator can reduce this latency and this is particularly important when trying to match feedback to sound or visual cues.

Impact Feedback

We use the UIImpactFeedbackGenerator subclass.

We create an instance of UIImpactFeedbackGenerator by passing the style of the impact feedback than can be .light.medium or .heavy , then we just trigger feedback by calling .impactOccurred() generator’s method.

Notification Feedback

We use the UINotificationFeedbackGenerator subclass.

We create an instance of UINotificationFeedbackGenerator, then trigger the notification feedback by calling .notificationOccurred(notificationType:) generator’s method that receives as parameter one of the three notification types .error.warning or .success .

Selection Feedback

We use the UISelectionFeedbackGenerator subclass.

We create an instance of UISelectionFeedbackGenerator, then trigger the notification feedback by calling .selectionChanged() generator’s method.

Remember: .prepare() can be optional for all generators if you are willing to deal with the latency(milliseconds) for each feedback generator.


There is no great genius without some touch of madness
— Aristotle

Thanks for reading and hope you find this article helpful. As usual any feedback or comment is welcome. And if you want to waste some of your time, follow me on twitter @guerrix