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.
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