When interacting with a button with VoiceOver, the accessibility label is repeated to the user. If you are playing some audio, it could be difficult to listen to it properly. To avoid that, you can add the .startsMediaSession accessibility trait.

An app for learning Dutch has an audio clip to play how you would say Hi. When the play button is focused with VoiceOver, it says: “Play, button”. If you double tap the play button, VoiceOver will say: “Play” at the same time that the audio clip plays, saying: “Hoi!”. If you add the starts media session accessibility trait, VoiceOver won’t say anything back when double tapping the button, and you’ll just hear the audio clip saying: “Hoi!”.

You may also find interesting...

If you use SwiftLint in your SwiftUI project, there is a rule, by @rerycole34, for making sure that your images have either an accessibility label or are hidden for assistive tech because they might be decorative. Rule: https://realm.github.io/SwiftLint/accessibility_label_for_image.html

There is another accessibility trait: .playsSound, that does a similar thing than .startsMediaSession. This one seems more suitable for buttons that have their own sound effects when interacting with them, like it often happens in games.

When presenting a UI component that overlays the existing UI, you may have found that VoiceOver starts to randomly jump between the overlaid UI and the elements underneath. To avoid that, you can set its accessibilityViewIsModal to true. When setting the accessibilityViewIsModal to true for a view, VoiceOver will ignore its sibling views, treating it as if it was a modal. Useful when presenting custom popups, popovers, modals, action sheets, etc. https://developer.apple.com/documentation/objectivec/nsobject-swift.class/accessibilityviewismodal

Created in Swift with Ignite.

Supporting Swift for Swifts