Search code examples
iosswiftaccessibility

how to add accessibility to interactive dismissal of presented view controller


I have a view controller which can be dismissed by swiping down. How can I make it accessible for the visually impaired users. Is there any gesture to close the screen which I can add as accessibility label or trait.


Solution

  • First of all, as mentioned in comments, you should provide an alternative other than a gesture to close your widget. There are several good reasons to do so:

    • When VoiceOver or any other assistive tool is active, most gestures are totally absorbed for its own function and don't go through to your app. As a consequence, it becomes excessively painful if not completely impossible to close your widget.
    • Users using voice control or the new iOS 18 eyetracking feature, use those tools maybe especially because they aren't able to touch the screen or not comfortably, and for them too, if there's no button or anything, they can't close the widget either.

    AS a bonus, ideally, you should react to the VoiceOver back gesture, too. It is also known as Z gesture, because it consists of drawing a shape ressembling a Z with two fingers.

    This gesture allows to go back or close something without the need to find a close button anywhere on the screen, and so is a lot faster.

    Note that another quick go back gesture similarely exists for Talkback on Android, so this answer can in principle also apply to any mobile device.