Accessibility in iOS
Accessibility is about making things usable for everyone, specifically those who might not be as able as the majority of people (this webpage provides a pretty good introduction if this is all new to you).
In 2019 I went to two iOS conferences, Hacking with Swift Live and iOSDevUK. Both had talks on accessibility and it really inspired me to take the first steps in improving my personal apps for accessibility users.
Near the end of 2019 I decided to take my first released app (over 5 years ago it first graced the App Store) and redo it in SwiftUI and add in some improved support for accessibility. Having delved into the world of accessibility (shamefully, for the first time in my 7 years of iOS development) I thought I’d share what I’d found and try and encourage more people to consider some aspects of it.
“But I don’t have time for accessibility…”
Accessibility is probably something that most developers are aware of but most probably don’t a huge amount about it or spend much or any time on checking it or implementing it into their apps, often due to lack of time or budget.
Here’s an inspiring tweet:
Working on accessibility features is a wonderful thing. Sure, you could just care about the majority of your users and keep it simple, but go that extra mile for those less able and make their lives a bit better. But don’t forget to check for bugs in the different accessibility modes whenever you do a release. It’s not just a job that you can do once and forget about.
“So what should I be working on?”
Accessibility is quite a broad subject, here are some examples which I focussed on in my app:
- There are people who can’t see differences between colours that well.
- Avoid using red and green to solely signify state (also be careful of the meaning of colours in different countries).
- Don’t use colours together that don’t contrast well by testing your colour schemes with a contrast checker.
2. There are people with poor eyesight who can’t see small text.
- Make sure your text responds to the dynamic font sizing settings available in the Settings app.
3. There are those whose eyesight is even worse, perhaps unable to see anything at all.
- Make sure Voice Over works well.
Voice over is probably the hardest to do well I think. It’s fairly easy to make sure text displays ok at huge font sizes and it’s easy to make sure your colour scheme has a good contrast level.
“Isn’t Voice Over really awkward to support?”
For someone with good eyesight it’s a very different experience to use an app with Voice Over as there are lots of different gestures to do funky things and buttons require a double tap to trigger (as a single tap simply reads out what the button is for). But there are people out there using this all the time, so spend a bit of time familiarising yourself with how it works and seeing if there’s anything being read out that doesn’t sound right and could be improved.
I’ve heard that UIKit was quite difficult to get working well with Voice Over when you had custom components and layouts, requiring a lot of extra layout code. SwiftUI on the other hand makes life so much easier as there’s a lot of accessibility built in by default and the way you construct your layouts makes it much easier to provide good Voice Over behaviour. For more info on this read Rob Whitaker’s article (he was one of guys I saw talk on accessibility in 2019 that inspired me, he’s super into it!).
“Any tips for handling multiple colour schemes?”
iOS has an accessibility setting to turn on ‘high contrast’ colours, for those who struggle to differentiate colours. Your app can detect that that setting is enabled and swap out its colour scheme, but that sounds like a lot of work, right?
Xcode allows you to put your colours into your asset catalogs (where you store your images) and then refer to them by name. It also lets you specify high contrast (and dark mode) versions of those colours so your code can be nice and clean without having to check what colour should be shown for which mode (check out the ‘Appearances’ section in the Attributes Inspector of a colour in an asset catalog).
This seems to work great in UIKit and the dark mode versions work great in SwiftUI too but, in Xcode 11.2 at least, I was unable to get the high contrast colours to be used in SwiftUI when the setting in the Settings app was enabled, which is a shame. So for that I had to do a custom approach where I had two colours in the asset catalog, e.g. ‘primaryColour’ and ‘primaryColourHC’ and then pick the right one based on the colorSchemeContrast environment variable:
@Environment(\.colorSchemeContrast) var contrastSetting: ColorSchemeContrast
switch contrastSetting {
case .increased:
Color(“primaryColourHC”)
case .standard:
Color(“primaryColour”)
}
Quite often making improvements to your app for accessibility users can make it better for all your other users too.
“Is there any easy way to find issues?”
Xcode provides a tool called the Accessibility Inspector, which can be used to audit your app for any accessibility issues. I’ve heard this suggested as a great starting point for finding issues so give it a try. Personally I found that it flagged up quite a lot of false positives in my app, which is odd, but maybe that’s another teething issue with SwiftUI!
“I’m still not convinced…”
Here’s another interesting take on investing in accessibility:
That statement from Jeff Watkins isn’t necessarily true for everyone, but most people’s eyesight will degrade as they age and may get to a point where they need accessibility features, so don’t be someone who didn’t care when you didn’t need it and then get upset if you do need it and find nobody else has cared!
And if you can’t muster up the will to do something nice for others less able than you (and you make money from your apps) then think about the extra sales you can rack up if you can reach out to more people and get them excited about your app, maybe even featuring on a list of ‘especially accessible apps’ that gets you more exposure.
But why stop with our apps?
It’s not just in our apps that we should think about accessibility, you should do whatever you can to make sure everything you do is accessible. Twitter have a setting you can enable so you can add a description to an image you tweet to help those with poor eyesight (why it’s not something that’s enabled by default I can’t imagine, but at least they’ve added it):