Search code examples
iosswiftaccessibility

How to set Expand and Collapse state in ios swift for VoiceOver?


I'm trying to find out how to set the Expand and Collapse state for the VoiceOver screen reader, but I can't find it in any documentation or forums.

On Android it's AccessibilityNodeInfoCompat.ACTION_EXPAND or AccessibilityNodeInfoCompat.ACTION_COLLAPSE. I would like to find the equivalent for SWIFT IOS. Could anybody help me?


Solution

  • UIAccessibilityTraits is how states are indicated. It's part of UIAccessibility and not part of Swift, but you can set UIAccessibilityTraits from Swift. However, iOS does not have a natively supported expand/collapse property, unlike Android. You'll have to code around it by using accessibilityHint.