visionOS Accessibility

AccessibilityComponent

Similar to using the SwiftUI Accessibility API for SwiftUI elements, RealityKit’s AccessibilityComponent lets you customize a RealityKit entity’s label, value, and traits. In addition, you can customize an entity’s actions and content. You initialize a default AccessibilityComponent, set values for its properties, then assign it to the entity’s components set as the AccessibilityComponent.self element:

var accessibilityComponent = AccessibilityComponent()
accessibilityComponent.label = "Plane"
accessibilityComponent.value = "Flying"
accessibilityComponent.isAccessibilityElement = true
accessibilityComponent.traits = [.button, .playsSound]
accessibilityComponent.systemActions = [.activate]
scene.components[AccessibilityComponent.self] = accessibilityComponent

AccessibilityNotification Announcements

The four types of AccessibilityNotification are available on all platforms:

  • Announcement: A notification that an app posts when it needs to convey an announcement to an assistive app.
  • LayoutChanged: A notification that an app posts when the layout of a screen changes.
  • ScreenChanged: A notification that an app posts when a new view appears that occupies a major portion of the screen.
  • PageScrolled: A notification that an app posts when a scroll action completes.

Announcements can be particularly useful in visionOS apps where it’s critical to provide information about what items are available and where they are located:

AccessibilityNotification.Announcement("Plane stopped flying").post()

In the next video, you’ll try out these tools in a visionOS app.

See forum comments
Download course materials from Github
Previous: Demo: Dynamic Type & Contrast Ratio Next: Demo: Accessibility Traits & Announcements