In iOS, how to set accessibility focus to a button through programmatically?
Asked
Active
Viewed 3,468 times
1
-
Do you mean making a button active? – sangony Feb 09 '14 at 17:19
3 Answers
0
You can do this via following notifications:
UIAccessibilityLayoutChangedNotification
or
UIAccessibilityScreenChangedNotification
E.g.
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, yourElement);

Rahil Wazir
- 10,007
- 11
- 42
- 64

ClemensL
- 404
- 2
- 10
0
@ClemensL response works great. Here is a Swift 5 version:
func setAccessibilityFocus() {
UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: self)
}

Sebbo
- 326
- 4
- 10
-1
You can set focus to any UI element by using the following snippet.
UIAccessibility.setFocusTo(your-UI-element)

Govind
- 84
- 7