UIHoverEffectLayer
A layer type that can be used to apply a hover effect to its sublayers.
Declaration
@MainActor class UIHoverEffectLayerOverview
This layer type is useful for adding hover effects to an existing CALayer hierarchy. Where possible, use UIView.hoverStyle instead.
A UIHoverEffectLayer is configured with:
A container 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.
A 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 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.