Contents

init(title:subtitle:image:identifier:options:preferredElementSize:children:)

Creates a new menu with the specified title, subtitle, image, identifier, menu options, element size, and child elements.

Declaration

@MainActor @preconcurrency convenience init(title: String = "", subtitle: String? = nil, image: UIImage? = nil, identifier: UIMenu.Identifier? = nil, options: UIMenu.Options = [], preferredElementSize: UIMenu.ElementSize = { if #available(iOS 17.0, tvOS 17.0, watchOS 10.0, *) { .automatic } else { .large } }(), children: [UIMenuElement] = [])

Parameters

  • title:

    The title of the menu.

  • subtitle:

    The subtitle of the menu.

  • image:

    The image to display next to the menu’s title.

  • identifier:

    The unique identifier for the menu. When creating standard menus for your app, specify an appropriate constant defined in Identifier Swift.struct. For custom menus, specify a custom reverse domain name value, or specify nil to let this method create a unique identifier for you.

  • options:

    Additional configuration options for the menu. For a list of possible values, see Options Swift.struct.

  • preferredElementSize:

    The size of the menu’s child elements. For a list of possible values, see Elementsize.

  • children:

    The menu elements in the menu. Specify leaf menu elements using Uimenuelement subclasses like Uiaction, Uicommand, or Uikeycommand, and specify submenus using Uimenu objects. You may specify an empty array if the menu has no child menu elements.

See Also

Creating a menu object