visionOS Accessibility

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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:

AccessibilityNotification.Announcement("Plane stopped flying").post()
See forum comments
Download course materials from Github
Previous: Demo: Dynamic Type & Contrast Ratio Next: Demo: Accessibility Traits & Announcements