Handling Double Taps from Apple Pencil

Overview

You can use Pencil interactions to allow users to access functionality in your app quickly. Double-tapping the Apple Pencil lets the user perform actions such as switching between drawing tools without moving the Pencil to another location on the screen.

Handle the Double Tap

The delegate receives the double tap event when the user double-taps their Pencil. It implements the pencilInteractionDidTap(_:) method, which the system calls after the user double-taps the Apple Pencil.

In your implementation of this method, decide whether to perform the action selected by the user in the Settings app, or perform an alternative behavior that’s suitable for your app. When possible, perform the user’s preferred action.

Taking this step allows you to provide a consistent user experience across apps that support Pencil interactions. To check the user’s preferred action, use the preferredTapAction class property on UIPencilInteraction, as in Listing 2.