One Logo Pool Ball
SwiftUICore · IOS API REFERENCE

CustomHoverEffect

protocol · iOS 18.0+ · SDK 27.1

protocol CustomHoverEffect

A type that represents how a view should change when a pointer hovers over a view, or when someone looks at the view. Custom hover effects apply their inactive values when the effect is inactive, and their active values when the effect is active. For example, the following effect causes a view to be partially transparent when inactive, but animate to fully opaque when active: struct FadeInHoverEffect: CustomHoverEffect { func body(content: Content) -> some CustomHoverEffect { content.hoverEffect { effect, isActive, proxy in effect.animation(.easeOut) { $0.opacity(isActive ? 1 : 0.5) } } } } This effect can be applied to a view using the `hoverEffect(_:)` modifier: Color.red .hoverEffect(FadeInHoverEffect()) Hover effects do not affect a view's layout, and may be applied to a view out-of-process. Therefore an effect's current phase may not be visible within your app.

Members (1)

method · iOS 18.0+

body

Swift declaration
func body(content: Self.Content) -> Self.Body

Defines the effect produced by this effect. You implement this method to describe a custom effect to apply to a view. `content` is an empty effect you use to build your effect, which will later be applied to a View, or combined with other `CustomHoverEffect`s. - Parameter content: An empty effect you use to compose the custom effect. - Returns: A custom effect.

Skipped declarations

4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

CustomHoverEffect.automatic

Static protocol requirements cannot be called through an instance.

CustomHoverEffect.highlight

Static protocol requirements cannot be called through an instance.

CustomHoverEffect.lift

Static protocol requirements cannot be called through an instance.

CustomHoverEffect.hoverEffectDisabled(_:)

This protocol needs associated types that cannot yet cross the bridge.

All SwiftUICore types →