<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIMenuBuilder",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UIMenuBuilder"
  },
  "title" : "UIMenuBuilder"
}
-->

# UIMenuBuilder

An interface for adding and removing menus from a menu system.

```
@MainActor protocol UIMenuBuilder
```

## Overview

You don’t create a menu builder object. Instead, you override [`buildMenu(with:)`](/documentation/UIKit/UIResponder/buildMenu(with:)) in your app delegate or view controller to receive a builder object. Where you override this method determines the system that the builder updates. To add and remove menus from the menu bar using the [`main`](/documentation/UIKit/UIMenuSystem/main) menu system, override [`buildMenu(with:)`](/documentation/UIKit/UIResponder/buildMenu(with:)) in your app delegate. To build a context menu using the [`context`](/documentation/UIKit/UIMenuSystem/context) system, override the method in your view controller.

To see an example of how to use a menu builder object, see [Adding menus and shortcuts to the menu bar and user interface](/documentation/UIKit/adding-menus-and-shortcuts-to-the-menu-bar-and-user-interface).

## Topics

### Getting menu systems and elements

[`var system: UIMenuSystem`](/documentation/UIKit/UIMenuBuilder/system)

The menu system that the menu builder modifies.

[`func menu(for: UIMenu.Identifier) -> UIMenu?`](/documentation/UIKit/UIMenuBuilder/menu(for:))

Gets the menu for the specified menu identifier.

[`func action(for: UIAction.Identifier) -> UIAction?`](/documentation/UIKit/UIMenuBuilder/action(for:))

Gets the action for the specified action identifier.

[`func command(for: Selector, propertyList: Any?) -> UICommand?`](/documentation/UIKit/UIMenuBuilder/command(for:propertyList:))

Gets the command for the specified selector and property list.

[`- (UICommand *) commandForAction:(SEL) action propertyList:(id) propertyList;`](/documentation/UIKit/UIMenuBuilder/commandForAction:propertyList:)

Gets the command for the specified selector and property list.

### Inserting child menus

[`func insertChild(UIMenu, atStartOfMenu: UIMenu.Identifier)`](/documentation/UIKit/UIMenuBuilder/insertChild(_:atStartOfMenu:))

Adds a child menu as the first element of the specified parent menu.

[`func insertChild(UIMenu, atEndOfMenu: UIMenu.Identifier)`](/documentation/UIKit/UIMenuBuilder/insertChild(_:atEndOfMenu:))

Adds a child menu as the last element of the specified parent menu.

### Inserting sibling menus

[`func insertSibling(UIMenu, beforeMenu: UIMenu.Identifier)`](/documentation/UIKit/UIMenuBuilder/insertSibling(_:beforeMenu:))

Inserts a sibling menu before the specified menu.

[`func insertSibling(UIMenu, afterMenu: UIMenu.Identifier)`](/documentation/UIKit/UIMenuBuilder/insertSibling(_:afterMenu:))

Inserts a sibling menu after the specified menu.

### Replacing menus and child menu elements

[`func replaceChildren(ofMenu: UIMenu.Identifier, from: ([UIMenuElement]) -> [UIMenuElement])`](/documentation/UIKit/UIMenuBuilder/replaceChildren(ofMenu:from:))

Replaces the elements in a menu with the elements returned by the specified handler block.

### Removing a menu

[`func remove(menu: UIMenu.Identifier)`](/documentation/UIKit/UIMenuBuilder/remove(menu:))

Removes a menu from the menu system.

### Instance Methods

[`func insertElements([UIMenuElement], afterAction: UIAction.Identifier)`](/documentation/UIKit/UIMenuBuilder/insertElements(_:afterAction:))

Insert elements after an identified action.

[`func insertElements([UIMenuElement], afterCommand: Selector, propertyList: Any?)`](/documentation/UIKit/UIMenuBuilder/insertElements(_:afterCommand:propertyList:))

[`func insertElements([UIMenuElement], afterMenu: UIMenu.Identifier)`](/documentation/UIKit/UIMenuBuilder/insertElements(_:afterMenu:))

Insert elements after an identified menu.

[`func insertElements([UIMenuElement], atEndOfMenu: UIMenu.Identifier)`](/documentation/UIKit/UIMenuBuilder/insertElements(_:atEndOfMenu:))

Insert elements at the end of an identified parent menu.

[`func insertElements([UIMenuElement], atStartOfMenu: UIMenu.Identifier)`](/documentation/UIKit/UIMenuBuilder/insertElements(_:atStartOfMenu:))

Insert elements at the start of an identified parent menu.

[`func insertElements([UIMenuElement], beforeAction: UIAction.Identifier)`](/documentation/UIKit/UIMenuBuilder/insertElements(_:beforeAction:))

Insert elements before an identified action.

[`func insertElements([UIMenuElement], beforeCommand: Selector, propertyList: Any?)`](/documentation/UIKit/UIMenuBuilder/insertElements(_:beforeCommand:propertyList:))

[`func insertElements([UIMenuElement], beforeMenu: UIMenu.Identifier)`](/documentation/UIKit/UIMenuBuilder/insertElements(_:beforeMenu:))

Insert elements before an identified menu.

[`func remove(action: UIAction.Identifier)`](/documentation/UIKit/UIMenuBuilder/remove(action:))

Remove an identified action.

[`func remove(command: Selector, propertyList: Any?)`](/documentation/UIKit/UIMenuBuilder/remove(command:propertyList:))

[`func replace(action: UIAction.Identifier, with: [UIMenuElement])`](/documentation/UIKit/UIMenuBuilder/replace(action:with:))

Replace an identified action with menu elements.

[`func replace(command: Selector, propertyList: Any?, with: [UIMenuElement])`](/documentation/UIKit/UIMenuBuilder/replace(command:propertyList:with:))

[`func replace(menu: UIMenu.Identifier, with: [UIMenuElement])`](/documentation/UIKit/UIMenuBuilder/replace(menu:with:)-8mwou)

Replace an identified menu with menu elements.

[`func replace(menu: UIMenu.Identifier, with: UIMenu)`](/documentation/UIKit/UIMenuBuilder/replace(menu:with:)-95tg2)

Replace an identified menu with a menu.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)