init(_:image:role:intent:)
Creates a button with a specified role that generates its label from a string and an image resource.
Declaration
nonisolated init(_ title: some StringProtocol, image: ImageResource, role: ButtonRole? = nil, intent: some AppIntent)Parameters
- title:
A string that describes the purpose of the button’s
intent. - image:
The image resource to lookup.
- role:
An optional semantic role describing the button. A value of
nilmeans that the button doesn’t have an assigned role. - intent:
The
AppIntentto execute.
Discussion
This initializer creates a Label view on your behalf, and treats the title similar to init(_:). See Text for more information about localizing strings.