Accessibility label - SwiftUI

In SwiftUI, the accessibilityLabel(_:) view modifier is used to assign an accessibility label to a view. It's essential to keep the accessibility label concise yet meaningful for optimal usability.

Image("appt_logo")
    .accessibilityLabel("Appt logo")

You can enhance accessibility in SwiftUI by using the Text initializer with an AttributedString parameter, offering precise control over pronunciation. For instance, you can spell out each character using .accessibilitySpeechPunctuation or specify a language with .accessibilitySpeechLanguage.

let attributeContainer = AttributeContainer([
    .accessibilitySpeechPunctuation: true,
    .accessibilitySpeechLanguage: "en_US"
])

// Initialize `AttributedString` with the desired text and the `AttributeContainer`
let attributedString = AttributedString("Appt", attributes: attributeContainer)
Text(attributedString)

When dealing with long labels, consider using accessibilityInputLabels to provide alternative labels. The primary label comes first in the array, followed by optional alternative labels arranged in decreasing order of relevance.

Link(destination: URL(string: "https://appt.org/en/")!, label: {
    Text("Appt.org")
})
// Primary and alternative labels in descending order of importance
.accessibilityInputLabels([
    "Appt website",
    "Appt"
])