Declaration
compose().accessibilityLabel(label: string)nonisolated func accessibilityLabel(_ label: Text) -> Text3 more Swift overloads share this form
@export(implementation) nonisolated func accessibilityLabel(
_ label: LocalizedStringResource
) -> Textnonisolated func accessibilityLabel(
_ labelKey: LocalizedStringKey
) -> Textnonisolated func accessibilityLabel<S>(
_ label: S
) -> Text
where S : StringProtocolParameters
label*stringThe text view to add the label to.
Discussion
Use this method to provide an alternative accessibility label to the text that is displayed. For example, you can give an alternate label to a navigation title:
var body: some View {
NavigationView {
ContentView()
.navigationTitle(Text("").accessibilityLabel("Inbox"))
}
}You can't style the label that you add
See also
More in Text modifiers.
- accessibilityHeadingSets the accessibility level of this heading.
- accessibilityTextContentTypeSets an accessibility text content type.
- baselineOffsetSets the vertical offset for the text relative to its baseline.
- boldApplies a bold font weight to the text.
- fontSets the default font for text in the view.
- fontDesignSets the font design of the text.
- fontWeightSets the font weight of the text.
- fontWidthSets the font width of the text.
- foregroundStyleSets the style of the text displayed by this view.
- italicApplies italics to the text.
- kerningSets the spacing, or kerning, between characters.
- monospacedModifies the font of the text to use the fixed-width variant of the current font, if possible.