Haptics engage people's sense of touch to enhance the experience of interacting with onscreen interfaces. For example, when an Apple Pay transaction is confirmed, the system plays haptics in addition to providing visual and auditory feedback. Haptics can also enhance touch gestures and interactions like scrolling through a picker or toggling a switch.
On supported iPhone models, you can add haptics to your app in several ways.
- Use standard UI elements—like switches, sliders, and pickers—that play Apple-designed system haptics by default.
- When it makes sense, use a feedback generator to play one of several predefined haptic patterns in the categories of notification, impact, and selection. For developer guidance, see UIFeedbackGenerator.
- In situations where you want more control, compose and play your own haptic patterns. For guidance, see Creating Custom Haptic Patterns.
When you use system haptics, iOS manages the strength and behavior of the feedback. For example, a switch automatically plays a subtle tap and a feedback generator for the "success" notification plays the pattern shown below. (For developer guidance, see Animation and Haptics.)
Whether you use system-provided haptics or create your own, it's crucial to use haptics in ways that enrich the user experience without distracting people from their goals.
Designing with Haptics
Designing interfaces that engage people's sense of touch can bring their familiarity with the physical world into your app. Regardless of how you produce the haptics in your app, the following guidelines can help you give people a cohesive and compelling experience.
Build a clear, causal relationship between each haptic and its trigger. Ideally, people always know why your app plays a haptic pattern. If a haptic doesn't reinforce a cause-and-effect relationship, it can be confusing and seem gratuitous.
Use haptics in ways that complement other feedback in your app. When your app's visual, auditory, and tactile feedback are in harmony—as they are in the physical world—the user experience is more coherent and can seem more natural.
Use haptics judiciously. For example, use haptics when they provide long-lasting value; using them to add novelty can make your app feel gimmicky. Also, prefer adding haptics to a small number of significant, consequential interactions. Playing haptics for a large number of trivial interactions can overwhelm people.
Use haptics consistently. Consistency in haptic feedback helps people develop tactile associations between certain haptic patterns and certain experiences. For example, if your app plays a specific haptic pattern when a game character fails to finish a mission, people learn to associate that pattern with a negative outcome. If you use the same haptic pattern for a positive outcome like a level completion, people will be confused.
Avoid overusing a haptic. Sometimes a haptic can feel just right when experienced occasionally, but become tiresome when it's experienced frequently. In general, avoid designing an experience that yields extended or repetitive haptic feedback. Often, the best haptic experience is one that people may not be conscious of, but miss when it's turned off.
Be sure to test the haptics in your app. Different people have different preferences and levels of sensitivity to haptics, so you need to test the haptics with as many people as possible.
Make haptics optional. Let people turn off or mute haptics if they wish, and make sure people can still enjoy your app without them.
In a game, consider ways to use custom haptics to enhance the player's experience. In addition to playing haptics when players interact with items and controls, you might want to play haptics that help communicate in-game events. For example, haptics could enhance substantial experiences—like a collision or a hit—or subtle experiences—like the approach of footsteps or a looming danger.
Be conscious that playing haptics might impact other user experiences. By design, haptics produce enough physical force for people to feel the device vibrate. Ensure that haptics don’t disrupt user experiences involving the camera, gyroscope, or microphone.
Creating Custom Haptic Patterns
A custom haptic pattern can represent things like releasing a slingshot or driving over a rumble strip. Custom patterns can also vary dynamically, based on user input or context. For example, the impact players feel when a game character jumps from a tree can be stronger than when the character jumps in place.
In iOS 13 and later, Core Haptics provides two basic building blocks that generate custom haptic patterns:
- Transient events, which are brief, compact experiences that feel like taps or impulses, such as the experience of tapping the Flashlight button on the Home screen
- Continuous events, which feel like sustained vibrations, such as the experience of the lasers effect in a message
Regardless of the building block you choose to generate a custom haptic, you can also control its sharpness and intensity. You can think of sharpness as a way to abstract a haptic experience into the waveform that produces the corresponding physical sensations. Specifying sharpness lets you relay to the system your intent for the experience. For example, you might use sharpness values to convey an experience that's soft, rounded, or organic, or one that's crisp, precise, or mechanical. As the term implies, intensity means the strength of the haptic.
By combining transient and continuous events, varying sharpness and intensity, and including optional audio content, you can create a wide range of different haptic experiences. For developer guidance, see Core Haptics.