I just completed day 74 of 100 days of SwiftUI. Today, I learnt about Accessibility.
App accessibility simply means developing apps for disabled users in mind. An app is truly accessible if a disabled user can use all of its features perfectly.
There are many ways to make your app accessible:
Use meaningful labels: Since your app would be read out loud by accessibility software like VoiceOver for iOS or TalkBack for Android. It's always best to use meaningful names as labels. You can give views that an accessibility label using the
Hide non-accessible views: Sometimes, some views are decorative. For disabled users, these views are simply distracting. To hide them, you can simply use the
accessibility(hidden: true)modifier function.
Group views: Sometimes, many views are used to display a single piece of information. In order to make these views accessible, you simply have to wrap the views in a
Vstackand use the
.accessibilityElement(children: .combine)or the
.accessibilityElement(children: .ignore)modifier on the
combine, makes the accessibility reader take the views as one. It will read all of them automatically but there will be a bit of a pause in between them. Using the
ignorewill simply ignore the labels. You can then manually add your label using the
accessibility(label: TextView)modifier. Using the second option, the accessibility software would read everything as one.
This is the second time I am learning about accessibility this week. We had a tech talk about testing for accessibility at work. It showed me the importance of app accessibility.
I'll leave you this breathtaking video about the power of app accessibility.