UIContextMenuInteraction
An interaction object that you use to display relevant actions for your content.
Declaration
@MainActor class UIContextMenuInteractionMentioned in
Overview
Use a UIContextMenuInteraction object to focus the user’s attention on a specific portion of your content, and to provide actions for the user to perform on that content. A context menu interaction object tracks Force Touch gestures on devices that support 3D Touch, and long-press gestures on devices that don’t support it. When the appropriate gesture occurs, this object animates your content to a new interface and displays the contextual menu that you supplied. UIKit manages all menu-related interactions and reports the selected action, if any, back to your app.
A context menu interaction object inherits from UIInteraction. After creating the object, assign an appropriate object to its delegate property and use the addInteraction(_:) method to attach it to one of your views. The delegate object you provide must adopt the UIContextMenuInteractionDelegate protocol. Use the methods of that object to provide the contents of the contextual menu. Add your context menu interaction object to a view in your interface using the view’s addInteraction(_:) method.
Topics
Creating a context menu interaction object
init(delegate:)Adding context menus in your appAdding menus and shortcuts to the menu bar and user interface