View ModifieriOS 14.0+macOS 11.0+tvOS 14.0+watchOS 7.0+
Overloads
2 ways to call compose().userActivity(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().userActivity<P>(
activityType: string,
options: {
element: P | null;
update: { activityType?: string; title?: string; webpageURL?: string; userInfo?: Record<string, unknown>; isEligibleForHandoff?: boolean; isEligibleForSearch?: boolean; isEligibleForPrediction?: boolean; };
}
)nonisolated func userActivity<P>(
_ activityType: String,
element: P?,
_ update: @escaping (P, NSUserActivity) -> ()
) -> some ViewParameters
activityType*stringThe type of activity to advertise.
options.element*P | nullIf the element is
nil, the handler will not be associated with the activity (and if there are no handlers, no activity is advertised). The method passes the non-nilelement to the handler as a convenience so the handlers don't all need to implement an early exit withguard element = element else { return }.options.update*{ activityType?: string; title?: string; webpageURL?: string; userInfo?: Record<string, unknown>; isEligibleForHandoff?: boolean; isEligibleForSearch?: boolean; isEligibleForPrediction?: boolean; }A function that modifies the passed-in activity for advertisement.
Discussion
The scope of the activity applies only to the scene or window the view is in.
See also
More in Input and interaction.
- allowsHitTestingConfigures whether this view participates in hit test operations.
- allowsWindowActivationEventsConfigures whether gestures in this view hierarchy can handle events that activate the containing window.
- buttonRepeatBehaviorSets whether buttons in this view should repeatedly trigger their actions on prolonged interactions.
- disabledAdds a condition that controls whether someone can interact with this view.
- handlesExternalEventsSpecifies the external events that the view's scene handles if the scene is already open.
- helpAdds help text to a view using a localized string resource that you provide.
- invalidatableContentMark the receiver as their content might be invalidated.
- keyboardShortcutAssigns a keyboard shortcut to the modified control.
- scrollClipDisabledSets whether a scroll view clips its content to its bounds.
- scrollDisabledDisables or enables scrolling in scrollable views.
- scrollDismissesKeyboardConfigures the behavior in which scrollable content interacts with the software keyboard.
- sensoryFeedbackPlays the specified feedback when the provided trigger value changes.