<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIHoverEffectLayer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIHoverEffectLayer"
  },
  "title" : "UIHoverEffectLayer"
}
-->

# UIHoverEffectLayer

A layer type that can be used to apply a hover effect to its sublayers.

```
@MainActor class UIHoverEffectLayer
```

## Overview

This layer type is useful for adding hover effects to an existing
`CALayer` hierarchy. Where possible, use `UIView.hoverStyle` instead.

A [`UIHoverEffectLayer`](/documentation/UIKit/UIHoverEffectLayer) is configured with:

1. A container [`UIView`](/documentation/UIKit/UIView), which is used to infer some properties of the
   hover effect from its trait collection and to allow some aspects of the
   hover effect to behave correctly. This view’s layer should be an ancestor
   layer of the [`UIHoverEffectLayer`](/documentation/UIKit/UIHoverEffectLayer).
2. A [`UIHoverStyle`](/documentation/UIKit/UIHoverStyle), which describes the effect to use and the shape of
   that effect. You then add your content layers that should receive a hover
   effect as sublayers of this layer.

[`UIHoverEffectLayer`](/documentation/UIKit/UIHoverEffectLayer) may add its own internal sublayers as background or
overlay layers relative to your content sublayers. To preserve the correct
appearance of the effect, these internal sublayers are automatically sorted
accordingly within the layer’s layout pass. As such, do not assume that the
indices of your content sublayers will remain stable throughout the lifetime
of the layer.

> Note: Not all ``doc://com.apple.uikit/documentation/UIKit/UIHoverStyle``s may be supported by
> ``doc://com.apple.uikit/documentation/UIKit/UIHoverEffectLayer``. If the provided style is not supported, a fallback
> style will be selected instead.

## Topics

### Initializers

[`init(containerView: UIView, style: UIHoverStyle?)`](/documentation/UIKit/UIHoverEffectLayer/init(containerView:style:))

Creates a [`UIHoverEffectLayer`](/documentation/UIKit/UIHoverEffectLayer) with the provided `containerView`
and `style`. If a `nil` `style` is provided, the automatic style will
be used instead.

### Instance Properties

[`var containerView: UIView?`](/documentation/UIKit/UIHoverEffectLayer/containerView)

The [`UIView`](/documentation/UIKit/UIView) in which this layer is contained. This view is used to
derive traits and other properties for applying the correct hover effect
to the layer. It may also be used to assist with applying some kinds of
hover effects to the layer.

[`var hoverStyle: UIHoverStyle`](/documentation/UIKit/UIHoverEffectLayer/hoverStyle)

The hover style to apply to the sublayers of this layer when this layer
is hovered (e.g., when the user looks at this layer). Defaults to the
automatic style.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CAMediaTiming`](/documentation/QuartzCore/CAMediaTiming)

[`Equatable`](/documentation/Swift/Equatable)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

### Inherits From

[`CALayer`](/documentation/QuartzCore/CALayer)

---

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)