The singleton UIMenu​Controller instance presents the menu interface for the Cut, Copy, Paste, Select, Select All, and Delete commands.


This menu is referred to as the editing menu. When you make this menu visible, UIMenu​Controller positions it relative to a target rectangle on the screen; this rectangle usually defines a selection. The menu appears above the target rectangle or, if there is not enough space for it, below it. The menu’s pointer is placed at the center of the top or bottom of the target rectangle, as appropriate. Be sure to set the tracking rectangle before you make the menu visible. You are also responsible for detecting, tracking, and displaying selections.

The UIResponder​Standard​Edit​Actions informal protocol declares methods that are invoked when the user taps a menu command. The can​Perform​Action(_:​with​Sender:​) method of UIResponder is also related to the editing menu. A responder implements this method to enable and disable commands of the editing menu just before the menu is displayed. You can force this updating of menu commands’ enabled state by calling the update() method.

You can also provide your own menu items via the menu​Items property. When you modify the menu items, you can use the update() method to force the menu to update its display.


Getting the Menu Controller Instance

class var shared:​ UIMenu​Controller

Returns the menu controller.

Showing and Hiding the Menu

var is​Menu​Visible:​ Bool

The visibility of the editing menu.

func set​Menu​Visible(Bool, animated:​ Bool)

Shows or hides the editing menu, optionally animating the action.

Positioning the Menu

func set​Target​Rect(CGRect, in:​ UIView)

Sets the area in a view above or below which the editing menu is positioned.

var menu​Frame:​ CGRect

Returns the frame of the editing menu.

var arrow​Direction:​ UIMenu​Controller​Arrow​Direction

The direction the arrow of the editing menu is pointing.

Updating the Menu

func update()

Updates the appearance and enabled state of menu commands.

Customizing Menu Items

var menu​Items:​ [UIMenu​Item]?

The custom menu items for the editing menu.


static let UIMenu​Controller​Will​Show​Menu:​ NSNotification.Name

Posted by the menu controller just before it shows the menu.

static let UIMenu​Controller​Did​Show​Menu:​ NSNotification.Name

Posted by the menu controller just after it shows the menu.

static let UIMenu​Controller​Will​Hide​Menu:​ NSNotification.Name

Posted by the menu controller just before it hides the menu.

static let UIMenu​Controller​Did​Hide​Menu:​ NSNotification.Name

Posted by the menu controller just after it hides the menu.


Inherits From