Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to customise Accessibility label on the navigation bar back button?

I am trying to find a way to customise the accessibility label for the back button on the navigation bar for voiceover feature. I know the accessibilityLabel feature is used to customise the elements, however I can't seem to be able to do it for the navigation bar's back button. Any advice on how I should approach this issue?

I am developing on iOS 8, using Swift.

like image 947
Cherie CH. Avatar asked Sep 26 '22 12:09

Cherie CH.


1 Answers

No, you cannot use any other than accessibilityLabel to set the accessibilityLabel for an element. Your other otpion is setting the accessibilityHint. But you should always set the accessibilityLabel.

You can set the accessibility for the back button as:

You can customise your accessibilityLabel string but not accessibilityLabel.

Obj-C:

[self.navigationController.navigationBar.backItem setAccessibilityLabel:@"your string"];

Swift:

self.navigationController.navigationBar.backItem.setAccessibilityLabel("your string")

Swift 2.2

self.navigationController?.navigationBar.backItem?.accessibilityLabel = "your string"

You can also change the traits for an element.for that look into UIAccessibilityTraits

like image 143
Teja Nandamuri Avatar answered Sep 30 '22 08:09

Teja Nandamuri