DEV Community

Oluwasanmi Aderibigbe
Oluwasanmi Aderibigbe

Posted on

Day 74 of 100 Days of SwiftUI

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:

  1. 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 accessibility(label: TextView) modifier.

  2. 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.

  3. 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 Vstack and use the .accessibilityElement(children: .combine) or the .accessibilityElement(children: .ignore) modifier on the Vstack. Using 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 ignore will 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.
https://www.youtube.com/watch?v=XB4cjbYywqg

Top comments (0)