Overloads
2 ways to call compose().defaultHoverEffect(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().defaultHoverEffect(effect: SwiftUI.HoverEffect | null)nonisolated func defaultHoverEffect(_ effect: HoverEffect?) -> some ViewParameters
effect*SwiftUI.HoverEffect | nullThe default hover effect to use for views within this view.
Return value
A view that uses this effect as the default hover effect.
Discussion
Use this modifier to set a specific hover effect for all views with the
View.hoverEffect(_:) modifier applied within a view. The default
effect is typically used when no HoverEffect was provided or if
HoverEffect.automatic is specified.
For example, this view uses HoverEffect.highlight for both the red
and green Color views:
HStack {
Color.red.hoverEffect()
Color.green.hoverEffect()
}
.defaultHoverEffect(.highlight)This also works for customizing the default hover effect in views like
Buttons when using a SwiftUI-defined style like
ButtonStyle.bordered, which can provide a hover effect by default.
For example, this view replaces the hover effect for a Button with
HoverEffect.highlight:
Button("Next") {}
// perform action
}
.buttonStyle(.bordered)
.defaultHoverEffect(.highlight)Use a nil effect to indicate that the default hover effect should not
be modified.
See also
More in Gestures and input.
- defersSystemGesturesSets the screen edge from which you want your gesture to take precedence over the system gesture.
- dragConfigurationConfigures a drag session.
- dragContainerA container with draggable views. The drag payload is identifiable. To form the payload, use the identifier of the dragged view inside the container.
- dragContainerSelectionProvides multiple item selection support for drag containers.
- gestureAttaches a gesture to the view with a lower precedence than gestures defined by the view.
- handGestureShortcutAssigns a hand gesture shortcut to the modified control.
- highPriorityGestureAttaches a gesture to the view with a higher precedence than gestures defined by the view.
- hoverEffectApplies a hover effect to this view.
- hoverEffectDisabledAdds a condition that controls whether this view can display hover effects.
- presentationDragIndicatorSets the visibility of the drag indicator on top of a sheet.
- simultaneousGestureAttaches a gesture to the view to process simultaneously with gestures defined by the view.