UIAction
A menu element that performs its action in a closure.
Declaration
@MainActor class UIActionOverview
Create a UIAction object when you want a menu element that performs its action in a closure. The following example adds an action-based menu to the File menu:
// Create a closure-based action to use as a menu element.
let refreshAction = UIAction(title: "Refresh") { (action) in
print("Refresh the data.")
}
// Use the .displayInline option to avoid displaying the menu as a submenu,
// and to separate it from the other menu elements using a line separator.
let refreshMenuItem = UIMenu(title: "", options: .displayInline, children: [refreshAction])
// Insert the menu into the File menu before the Close menu.
builder.insertSibling(refreshMenuItem, beforeMenu: .close)Topics
Creating an action
init(title:subtitle:image:identifier:discoverabilityTitle:attributes:state:handler:)init(title:image:identifier:discoverabilityTitle:attributes:state:handler:)captureTextFromCamera(responder:identifier:)UIAction.IdentifierUIActionHandler