Accessibility element

How to develop accessible iOS apps

Jeroen de Vrind
Short Swift Stories

--

When a user navigates your app with an assistive technology, the interface is not the same as the one visible on the screen. They navigate a modified version that iOS creates, called the accessibility tree or Accessibility UI (AUI).

The difference between SwiftUI and UIKit is how iOS creates the AUI. In UIKit, iOS builds the visual interface and then generates an AUI from the screen. The accessibility API then combines this with any accessibility modifications you have made in code.

With complex UI or custom components, it can be hard for the API to interpret the experience you intended it to be. And if you change the interface by adding or removing elements on the same screen, the AUI doesn’t know about it, so you have to update it manually; otherwise, the UI and AUI differ.

Because SwiftUI is declarative, it separates ‘what’ to present from ‘how’ to present it. So you declare the ‘what’ by specifying the elements (Button, Image, Text) in code, and the platform decides how to present it.

The AUI can also interpret the code like your visual UI does and then decide how to present it in an accessible form.

Because SwiftUI views are structs, which are value types, iOS re-creates the views when the state changes. This…

--

--

Jeroen de Vrind
Short Swift Stories

iOS Engineer at ABN Amro bank. Author of How to develop accessible iOS apps.