ContextMenu

@available(tvOS, unavailable)
public struct ContextMenu

A container whose view content children will be presented as a menu items in a contextual menu after completion of the standard system gesture.

The controls contained in a ContextMenu should be related to the context they are being shown from.

See also

View.contextMenu, which attaches a ContextMenu to a View.
  • Important: Only Buttons with Image or Text are allowed as items. The following 3 view combinations are allowed for building a contextual menu:

    ContextMenu {
        // First combination
        Button(Text("Add")) {}
        // Second combination
        Button(action: {}) {
            Image()
        }
        // Third combination
        Button(action: {}) {
            Text("Add")
            Image()
        }
    }
    

    Declaration

    Swift

    public init(@ViewBuilder menuItems: () -> View)