Contents

init(_:image:role:action:)

Creates a button with a specified role that generates its label from a localized string resource and an image resource.

Declaration

@preconcurrency @export(implementation) nonisolated init(_ titleResource: LocalizedStringResource, image: ImageResource, role: ButtonRole?, action: @escaping @MainActor () -> Void)

Parameters

  • titleResource:

    Text resource for the button’s localized title, that describes the purpose of the button’s action.

  • image:

    The image resource to lookup.

  • role:

    An optional semantic role describing the button. A value of nil means that the button doesn’t have an assigned role.

  • action:

    The action to perform when the user triggers the button.

Discussion

This initializer creates a Label view on your behalf. See Text for more information about localizing strings.

See Also

Creating a button with a role