Making your app accessible is critical 💛
And SwiftUI gives us a lot of accessibility for free! Rob Whitaker from Capital One made a great series of 3–4 minutes guides on SwiftUI accessibility. There you can learn how to get the most from SwiftUI built-in features and make your app understandable for all users.
✍️ SwiftUI Accessibility: Traits
Accessibility traits are a group of attributes on a SwiftUI element. They inform assistive technologies on how to interact with element. Each element has a selection of default traits which you can change.
👀 SwiftUI Accessibility: Accessible User Interface
When customers enable an assistive technology to navigate your app, the interface isn’t exactly the same as the one visible on the screen. Users navigate a modified version that iOS creates especially for assistive technology. This is known as the accessibility tree or an accessible user interface. iOS does an incredible job at creating the AUI for you from your SwiftUI code.
💛 SwiftUI Accessibility: Attributes
We can help iOS in creating an Accessible User Interface by tweaking some element’s accessibility attributes. Setting some accessibility attributes through modifiers is a simple way to add more meaning and context for your assistive technology users.
🔚 SwiftUI Accessibility: Sort Priority
Assistive technology, such as VoiceOver, works in natural reading direction. In English, this means top left through to the bottom right. Mostly this is the right decision for assistive technology to make. This is the order anyone not using assistive technology would experience your app. Sometimes though, we make designs that don’t read in this way.
📣 SwiftUI Accessibility: Named Controls
One big accessibility improvement in SwiftUI comes in the form of named controls. Nearly all controls and some non-interactive views can take a Text view as part of their view builder. The purpose of this is to tie the meaning to the control.
🖼 SwiftUI Accessibility: Images
Images in SwiftUI are accessible by default. This is the opposite of what we’d experience in UIKit, where images are not accessible unless you set isAccessibilityElement to true. But there still some nuances you need to keep in mind!
📝 SwiftUI Accessibility: Dynamic Type
Like all accessibility features, Dynamic Type is about customization. Many of your customers, and maybe even you, are using Dynamic Type without even considering it an accessibility feature. Dynamic type allows iOS users to set the text to a size that they find comfortable to read. With SwiftUI it got superpowers.