This is a small trick I use to compose complex accessibility labels/values when, for a UI component, some elements might not be in all its instances. An array of optional Strings, compact map, and join all elements by a separator, like a comma.

A tweet from Sebastiaan de With as an example. A tweet accessibility label is composed of many elements: Some tweets in home start with why you are seeing the tweet (Received new replies, someone liked it, based on your likes, someone retweeted, etc); the profile image is skipped; the user name is always part of the label; some users are verified; the user handle is not part of the label by default (but it can be enabled in Twitter's settings); the date is always there; and so is the text of the tweet; the tweets can have attachments (like a link, video or image with alt text); and a tweet can be a promoted one. Then we could compose the tweet value with the number of reactions (replies, likes and retweets), if any. We can create an array of optional strings where we'll be storing all these strings. Then we can do compactMap to remove nils, we could filter to check for empty strings and remove them too, and then we can join all these components by a separator character.

You may also find interesting...

Do you have a fancy custom loading animation instead of an UIActivityIndicatorView? You may want to check if it has an accessibility label so a VoiceOver user knows that something is happening. Something like "In progress" or "Loading" could work.

When implementing a UISlider, it is a good idea to consider how much the slider value should change when swiping up/down to adjust it. It might not always make sense to do it in 10% increments, which is the default behaviour. Could be because the value at those intervals doesn't make sense, or feel random, or because it wouldn't provide the user with a fine enough control being able to go through the whole slider in just 10 swipes. It user will still be able to adjust the slider to any value by double tapping and holding and then moving the finger left or right, bypassing VoiceOver gestures. VoiceOver announces the new value as it changes.

An alternative layout for large font sizes can be provided with Auto Layout by having three sets of constraints (common, default constraints, and alternative constraints) and activate/deactivate them depending on the content size category.

Created in Swift with Ignite.

Supporting Swift for Swifts