---
title: "Support for Apple Pencil double tap in iOS PDF viewer | Nutrient"
canonical_url: "https://www.nutrient.io/guides/ios/annotations/apple-pencil-double-tap-actions/"
md_url: "https://www.nutrient.io/guides/ios/annotations/apple-pencil-double-tap-actions.md"
last_updated: "2026-05-18T06:34:32.253Z"
description: "Nutrient has built-in support for responding to double-taps on the second-generation Apple Pencil and Apple Pencil Pro. Read more in our release blog post."
---

# Support for Apple Pencil double tap on iOS

Nutrient has built-in support for responding to double-taps on the second-generation Apple Pencil and Apple Pencil Pro. Read more in [our release blog post](https://www.nutrient.io/blog/pspdfkit-ios-8-1/).

With Nutrient’s default configuration, you don’t need to do anything to enable Apple Pencil actions in your app. If you use a custom tools UI (rather than [`AnnotationToolbar`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationtoolbar)), then you need to implement a delegate method for full support. It is possible to disable or replace Nutrient’s handling of Apple Pencil actions.

## Default behavior

Apple Pencil double-tap actions are mostly handled by [`AnnotationStateManager`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationstatemanager). It has a [`pencilInteraction`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationstatemanager/pencilinteraction) property, which is an instance of `UIPencilInteraction`.

All cases of the `UIPencilPreferredAction` enum are handled as follows:

- `ignore` — Does nothing.

- `switchEraser` — If the state manager’s current state supports erasing (only ink), then switch to the eraser. If the current state is the eraser and the previous state supports erasing, then switch to the previous state.

- `switchPrevious` — Switches to the state manager’s previous non-`nil` state, or to `nil` if the previous state was set twice in a row.

- `showColorPalette` — Calls [`annotationStateManagerDidRequestShowingColorPalette(_:)`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationstatemanagerdelegate/annotationstatemanagerdidrequestshowingcolorpalette(_:)) on all delegates. [`AnnotationToolbar`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationtoolbar) implements this by showing the annotation inspector.

## Custom tools UI

If you use a custom UI instead of [`AnnotationToolbar`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationtoolbar), and if the UI uses [`AnnotationStateManager`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationstatemanager), then there’s not much more you need to do.

If your UI correctly observes changes to the state manager’s [state](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationstatemanager/state), then switching to the eraser or previous tool will work automatically.

To support the `UIPencilPreferredActionShowColorPalette`, you must provide a state manager delegate and implement [`annotationStateManagerDidRequestShowingColorPalette(_:)`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationstatemanagerdelegate/annotationstatemanagerdidrequestshowingcolorpalette(_:)), which is the [`AnnotationStateManagerDelegate`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationstatemanagerdelegate) method. The implementation would typically call [`toggleStylePicker(_:presentationOptions:)`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationstatemanager/togglestylepicker(_:presentationoptions:)) on the state manager, unless you want to show a custom color/style picker. [`AnnotationToolbar`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationtoolbar)’s implementation of this method simply follows the same code path as when its [`strokeColorButton`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/annotationtoolbar/strokecolorbutton) is tapped.

If your tools UI can be shown and hidden, be aware that actions will still be handled while the UI is hidden unless you disable the `UIPencilInteraction` with its `isEnabled` property.

## Custom actions

To perform a custom action in response to Apple Pencil double-tap actions, or to use your own implementation of the standard preferred actions, first you should disable Nutrient’s built-in handling. This can be done by removing the annotation state manager’s `pencilInteraction` from its view. Setting the `isEnabled` property will not work because Nutrient may set this property internally.

You can then add your own `UIPencilInteraction` to the view hierarchy and set its delegate to your own object. You can see this in action in `CustomPencilInteractionActionExample` in the Catalog example app.
---

## Related pages

- [Customizing Apple Pencil annotations on iOS](/guides/ios/annotations/apple-pencil.md)

