Skip to main content
Logo Appt Light

Accessibility link on iOS

Links should be accessible for users of assistive technologies. When accessibility is not taken into account, users might not be able to find or activate links.

On iOS, links should contain the link attribute. This attribute can be added through the addAttribute method of NSMutableAttributedString

To create text links, you can show the attributed string by using the the attributedText property of UILabel.

Depending on how your links are created, you might need to set the .link trait as accessibilityTraits.

guard let url = URL(string: "https://appt.org") else { return }
let link = "Appt"

let attributedString = NSMutableAttributedString(string: "Learn more about \(link)")

let range = attributedString.mutableString.range(of: link)
attributedString.addAttribute(.link, value: url, range: range)

let label = UILabel()
label.attributedText = attributedString

// Optional: add .link accessibility trait to whole label
label.accessibilityTraits = .link

Feedback?

Let us know!