---
title: UIHoverGestureRecognizer
framework: uikit
role: symbol
role_heading: Class
path: uikit/uihovergesturerecognizer
---

# UIHoverGestureRecognizer

A continuous gesture recognizer that interprets pointer movement over a view.

## Declaration

```swift
class UIHoverGestureRecognizer
```

## Mentioned in

Optimizing your iPad app for Mac

## Overview

Overview On macOS and iPadOS devices, a person can move the pointer over user interface elements. For some UI designs, it’s important to know when the pointer moves over an element, with no other user interactions, such as clicking the mouse button. The text for a hyperlink, for instance, may change colors or appear with an underline as the pointer moves over the link. This creates a rollover effect. note: On iOS, this class doesn’t recognize gestures. To provide this experience in your app, add a hover gesture recognizer that reacts as the pointer moves over the view. Provide the gesture recognizer with a target and action that the system calls when the pointer enters, exits, and moves across the view. UIHoverGestureRecognizer has no effect when your app runs in iOS. The following code changes the button’s default color to red as the pointer moves over the button. class ViewController: UIViewController {

@IBOutlet var button: UIButton!

override func viewDidLoad() {         super.viewDidLoad()

let hover = UIHoverGestureRecognizer(target: self, action: #selector(hovering(_:)))         button.addGestureRecognizer(hover)     }

@objc     func hovering(_ recognizer: UIHoverGestureRecognizer) {         switch recognizer.state {         case .began, .changed:             button.titleLabel?.textColor = #colorLiteral(red: 1, green: 0, blue: 0, alpha: 1)         case .ended:             button.titleLabel?.textColor = UIColor.link         default:             break         }     } }

## Topics

### Supporting Apple Pencil hover

- [altitudeAngle](uikit/uihovergesturerecognizer/altitudeangle.md)
- [azimuthAngle(in:)](uikit/uihovergesturerecognizer/azimuthangle(in:).md)
- [azimuthUnitVector(in:)](uikit/uihovergesturerecognizer/azimuthunitvector(in:).md)
- [rollAngle](uikit/uihovergesturerecognizer/rollangle.md)
- [zOffset](uikit/uihovergesturerecognizer/zoffset.md)

## Relationships

### Inherits From

- [UIGestureRecognizer](uikit/uigesturerecognizer.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### User interactions

- [Navigating an app’s user interface using a keyboard](uikit/navigating-an-app-s-user-interface-using-a-keyboard.md)
- [Adding menus and shortcuts to the menu bar and user interface](uikit/adding-menus-and-shortcuts-to-the-menu-bar-and-user-interface.md)
- [Handling key presses made on a physical keyboard](uikit/handling-key-presses-made-on-a-physical-keyboard.md)
