CustomHoverEffect
A type that represents how a view should change when a pointer hovers over a view, or when someone looks at the view.
Declaration
type CustomHoverEffect =
| 'automatic'
| 'highlight'
| 'lift'
| AutomaticHoverEffect
| HighlightHoverEffect
| HoverEffect
| LiftHoverEffect;protocol CustomHoverEffectPass a literal, or build one with SwiftUI.CustomHoverEffect from import { SwiftUI } from 'swiftui-react-native'.
Type properties
'automatic'SwiftUI.CustomHoverEffect.automaticThe default hover effect based on the surrounding context.
'highlight'SwiftUI.CustomHoverEffect.highlightA hover effect that highlights views using a light source to indicate position.
'lift'SwiftUI.CustomHoverEffect.liftA hover effect that slides the pointer under the view and disappears as the view scales up and gains a shadow.
Overview
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.
From Apple’s SwiftUI documentation. Code samples there are Swift.
Used by
See also
More in Gestures and input.
- AutomaticHoverEffectThe default hover effect based on the surrounding context.
- DragConfigurationThe behavior of the drag, proposed by the dragging source. A value that describes the drag operations a drag source supports.
- DragConfigurationOperationsOutsideAppDescribes the suggested drag operations to other applications.
- DragConfigurationOperationsWithinAppDescribes the drag operations suggested to destinations within the app.
- DragGestureA dragging motion that invokes an action as the drag-event sequence changes.
- DragGestureValueThe attributes of a drag gesture.
- DragSessionDescribes the ongoing dragging session.
- DragSessionIDThe identifier of a drag session.
- DragSessionPhaseThe phase of the current drag session
- GestureAn instance that matches a sequence of events to a gesture, and returns a stream of values for each of its states.
- GestureChainGesture with chained calls: SwiftUI.Gesture.exclusively(...).
- GestureInputKindsAn option set that specifies which input kinds a gesture should recognize.