iOS accessibility - How do you set the accessibility label for the title of a UINavigationBar?

Viewed 20259

Apple's voice over mispronounces the title of one of my views, which is inside a UINavigation Controller.

In other parts of the app I have added a custom accessibility label to help it pronounce the company name correctly. How can I set the accessibility label of a UINavigationBar?

4 Answers

There a similar workaround which I have tested on iOS 11 and 12 that works as expected. For the navigationItem.titleView set a UILabel object and then set your accessibility identifier for the navigationItem.titleView.

self.navigationItem.titleView = YOUR_CUSTOM_UILABEL;

accessibilityIdentifier part

self.navigationItem.titleView.accessibilityIdentifier = YOUR_ACCESSIBILITY_IDENTIFIER;

You can see your identifier with using Xcode's Accessibility Inspector.

Related