Day 52

UIColor accessibilityName for color labels

9 Jul 2022

Since iOS 14, you can get a human readable localised name for a UIColor, with a very useful property called accessibilityName, that you can use in accessibility attributes like labels or values. How cool is that?

https://developer.apple.com/documentation/uikit/uicolor/accessibilityname

iPad app for drawing sketches. It has a tool panel. The selected tool is a pen with the yellow color. There are some predefined colors to choose from. The fifth one is red. Using the accessibilityName from UIColor, we could configure an accessibility value for the pen, so VoiceOver would announce something like:

Some of you have asked me how you can support what I do. This would really help, and would be hugely appreciated:

  • Find these posts useful? Share them at work, on social media, or with anyone that might find them interesting. Let's spread the word!

  • Check out any of my apps or games: Xarra!, RetroRapid!, or Mestre!.

    • A download and a review go a long way. They're free by default. On the App Store, ratings and reviews really help more people discover them.

    • Finding any of them useful? If so, and if you can afford it, purchasing lifetime access to all features or subscribing lets me buy the coffee that keeps me caffeinated. Caffeine keeps me going to maintain the apps, bring in new features that I hope you'll love, and keep writing.

You may also find interesting...

"We have one job, and that's to make our apps work. And if you are not implementing accessibility features, you are forgetting about making it work for a lot of people" @NovallSwift Couldn't have said it better! https://x.com/novallswift/status/1328387659744505856

You don't have to offer an alternative layout just for the accessibility category. You can actually compare content size categories. So you could tweak the UI already for anything equal to or larger than .extraExtraLarge, for example.

All the accessibility capabilities you can check for, have counterpart notification names you can observe in case the user changes its preferences while using your app. https://x.com/dadederk/status/1577435144129892352


Content © Daniel Devesa Derksen-Staats on Accessibility up to 11! is licensed under CC BY 4.0. License details