<!--
{
  "documentType" : "article",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/pointer-interactions",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Pointer interactions"
}
-->

# Pointer interactions

Support pointer interactions in your custom controls and views.

## Discussion

iPadOS 13.4 introduces dynamic pointer effects and behaviors that enhance the experience of using an external input device, like a trackpad or mouse, with iPad. As people use an input device, iPadOS automatically adapts the pointer to the current context, providing rich visual feedback and just the right level of precision needed to enhance productivity and simplify common tasks.

[`UIKit`](/documentation/UIKit) automatically handles pointer interactions if you’re using [`UIButton`](/documentation/UIKit/UIButton), [`UIBarButtonItem`](/documentation/UIKit/UIBarButtonItem), or [`UISegmentedControl`](/documentation/UIKit/UISegmentedControl). If you use custom views to display your content, you must define pointer effects and styles yourself.

For more information, see [Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/inputs/pointing-devices/).

### Specify custom pointer styles

To add a custom pointer style effect to a view:

1. Create a [`UIPointerInteraction`](/documentation/UIKit/UIPointerInteraction) instance.
2. Specify the pointer interaction’s delegate (an object that conforms to the [`UIPointerInteractionDelegate`](/documentation/UIKit/UIPointerInteractionDelegate) protocol).
3. Add the interaction to the view’s [`interactions`](/documentation/UIKit/UIView/interactions) property.
4. Add the [`pointerInteraction(_:styleFor:)`](/documentation/UIKit/UIPointerInteractionDelegate/pointerInteraction(_:styleFor:)) delegate method.
5. Return [`UIPointerStyle`](/documentation/UIKit/UIPointerStyle) from that delegate method.

This example uses a custom helper method, which you typically call within a view controller’s [`viewDidLoad()`](/documentation/UIKit/UIViewController/viewDidLoad()) method:

```swift
func customPointerInteraction(on view: UIView, pointerInteractionDelegate: UIPointerInteractionDelegate) {
    let pointerInteraction = UIPointerInteraction(delegate: pointerInteractionDelegate)
    view.addInteraction(pointerInteraction)
}
```

The [`pointerInteraction(_:styleFor:)`](/documentation/UIKit/UIPointerInteractionDelegate/pointerInteraction(_:styleFor:)) delegate method is called when the pointer enters the view’s region. The following example shows an interaction that applies a [`UIPointerLiftEffect`](/documentation/UIKit/UIPointerLiftEffect) effect by returning a [`UIPointerStyle`](/documentation/UIKit/UIPointerStyle) object:

```swift
func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
    var pointerStyle: UIPointerStyle? = nil

    if let interactionView = interaction.view {
        let targetedPreview = UITargetedPreview(view: interactionView)
        pointerStyle = UIPointerStyle(effect: UIPointerEffect.lift(targetedPreview))
    }
    return pointerStyle
}
```

### Add interaction animations

Including animations can be helpful in pointer interactions, especially when views contain elements that interfere with pointer effects. For example, hiding the separator bars in a [`UISegmentedControl`](/documentation/UIKit/UISegmentedControl) when the pointer enters the control allows the active segment effect to appear visually uncluttered.

The following example performs a simple animation to change the alpha value of the view when the pointer enters and exits the region:

```swift
func pointerInteraction(_ interaction: UIPointerInteraction, willEnter region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
    if let interactionView = interaction.view {
        animator.addAnimations {
            interactionView.alpha = 0.5
        }
    }
}

func pointerInteraction(_ interaction: UIPointerInteraction, willExit region: UIPointerRegion, animator: UIPointerInteractionAnimating) {
    if let interactionView = interaction.view {
        animator.addAnimations {
            interactionView.alpha = 1.0
        }
    }
}
```

### Distinguish pointing device input events

If you want to distinguish between pointing device touch events and touch events from other sources, like the user’s fingers or Apple Pencil, you can enable the <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/UIApplicationSupportsIndirectInputEvents> key in the `Info.plist` file. With this key enabled, your app can respond to specific gestures targeted at touches of [`UITouch.TouchType.indirectPointer`](/documentation/UIKit/UITouch/TouchType/indirectPointer).

For more information, see <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/UIApplicationSupportsIndirectInputEvents>.

## Topics

### Essentials

[`UIPointerInteraction`](/documentation/UIKit/UIPointerInteraction)

An interaction that enables support for effects on a view or customizes the pointer’s appearance within a region of an app.

[`UIPointerInteractionDelegate`](/documentation/UIKit/UIPointerInteractionDelegate)

An interface for handling pointer movements within the interaction’s view.

[Integrating pointer interactions into your iPad app](/documentation/UIKit/integrating-pointer-interactions-into-your-ipad-app)

Support touch interactions in your iPad app by adding pointer interactions to your views.

[Enhancing your iPad app with pointer interactions](/documentation/UIKit/enhancing-your-ipad-app-with-pointer-interactions)

Provide a great user experience with pointing devices, by incorporating pointer content effects and shape customizations.

### Interaction animations

[`UIPointerInteractionAnimating`](/documentation/UIKit/UIPointerInteractionAnimating)

An interface for modifying an interaction animation in coordination with the pointer effect animations.

### Pointer styles

[`UIPointerStyle`](/documentation/UIKit/UIPointerStyle)

An object that defines the pointer shape and effect.

[`UIPointerShape`](/documentation/UIKit/UIPointerShape-swift.enum)

An object that defines the shape of custom pointers.

[`UIPointerEffect`](/documentation/UIKit/UIPointerEffect-swift.enum)

An effect that alters a view’s appearance when a pointer enters the current region.

[`UIPointerShape`](/documentation/UIKit/UIPointerShape-c.class)

An object that defines the shape of custom pointers.

[`UIPointerEffect`](/documentation/UIKit/UIPointerEffect-c.class)

An effect that alters a view’s appearance when a pointer enters the current region.

[`UIPointerAccessory`](/documentation/UIKit/UIPointerAccessory)

Constants that describe accessories to display alongside the primary pointer.

### Pointer region

[`UIPointerRegion`](/documentation/UIKit/UIPointerRegion)

A rectangular region that interacts with pointer movements.

[`UIPointerRegionRequest`](/documentation/UIKit/UIPointerRegionRequest)

An object to describe the pointer’s location in the interaction’s view.

### Lock state

[`UIPointerLockState`](/documentation/UIKit/UIPointerLockState)

An object that contains information about a scene’s pointer lock state.

### Band selection

[`UIBandSelectionInteraction`](/documentation/UIKit/UIBandSelectionInteraction)

An object that tracks the selection of multiple items using pointer-based input.

[`UIBandSelectionInteraction.State`](/documentation/UIKit/UIBandSelectionInteraction/State-swift.enum)

Constants that indicate whether a band selection interaction object is inactive or currently tracking an interaction.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)