What is the difference between isAccessibilityElement and accessibilityElementsHidden? The first one makes the view not accessible, but its subviews can still be accessible. The second one hides the view and all its subviews from assistive tech.

There is a view containing 4 subviews. Three examples. In the three of them, all the subviews (that we'll refer to as 1, 2, 3 and 4) have the isAccessibilityElement property set to true. In the first example, the superview (that we'll refer to as A) also has the isAccessibilityElement property to true. That means that A is accessible, but 1, 2, 3 and 4 aren't. In the second example A has the isAccessibilityElement property set to false. That means that A isn't accessible, but 1, 2, 3 and 4 are accessible. In the third example, A has isAccessibilityElement to false and accessibilityElementsHidden to true. That means that A, 1, 2, 3 and 4 will not be accessible.

You may also find interesting...

In SwiftUI there is a very useful modifier accessibilityElement(children:), that will do very different things depending on the AccessibilityChildBehavior passed as a parameter. There are three options: ignore (default), contain, and combine.

If you need for a view (and all its subviews) not to be focusable by assistive tech like VoiceOver, you can set its accessibilityElementsHidden property to true. This isn't needed very often, but it can be useful for certain custom experiences.

You can create your own accessibility elements from scratch. One use-case for doing that is when you do some custom drawing instead of building your UI using or relying on UIKit components. A circular progress bar, could be an example.

Created in Swift with Ignite.

Supporting Swift for Swifts