Skip to main content
Logo Appt Light

Accessibility focus on iOS

Sometimes you need to programmatically move the accessibility focus to a specific element. For example, when you present a modal, the assistive technology should move it's focus to it. Or when moving to a new screen, you might want assistive technologies to focus a specific element.

On iOS, you can use UIAccessibility to post a notification to move the focus of assistive technologies. Use screenChanged when a new view appears that occupies a major portion of the screen. Otherwise, use layoutChanged when the layout of current screen changes.

func focus(_ view: UIView) {
    UIAccessibility.post(notification: .layoutChanged, argument: view)
    UIAccessibility.post(notification: .screenChanged, argument: view)
}

Feedback?

Let us know!