IOS accessibility. How do you set the accessibility label for the name UINavigationBar?

Apple's voice makes it wrong to determine the title of one of my views, which is inside the UINavigation controller.

In other parts of the application, I added a special accessibility label to help her pronounce the company name correctly. How to set UINavigationBar accessibility label?

+7
source share
3 answers

I could not add an accessibility label, but found a workaround:

I will replace the ViewItem header with a UILabel that has accessibility.

UILabel *titleLabel = [[UILabel alloc] init]; titleLabel.text = @"myTitle"; [titleLabel setAccessibilityLabel:@"myCustomAccessiblityLabel"]; [titleLabel setFont:[UIFont boldSystemFontOfSize:20.0]]; [titleLabel setBackgroundColor:[UIColor clearColor]]; [titleLabel setTextColor:[UIColor whiteColor]]; [titleLabel sizeToFit]; self.navigationItem.titleView = titleLabel; 

I'm not sure why setting the accessibility label does not work, but the above code works for my needs.

+10
source

This works in iOS 8.2. In viewDidLoad :

 self.navigationItem.accessibilityLabel = @"My accessible label"; 

When the navigation controller goes to the view controller, the accessibilityLabel read instead of the title view controller.

+14
source

Since the UINavigationBar inherits from UIView , you must set its accessibilityLabel property. Try: yourUINavigationBar.accessibilityLabel = @"title"; .

In addition, you may need to make sure that it is marked as an accessibility element with yourUINavigationBar.isAccessibilityElement = YES; (and not inside another view, which is also marked as an accessibility element). (I suppose this last bit may be a problem, since it looks like you already knew about accessibility labels. You can use the Insibility Inspector in the simulator to make sure this is so by looking at the box around the item when you tap it to see if there’s anything more than a navigation bar around.)

0
source

All Articles