Question:
How do I add a custom VoiceOver accessibility
Label
orHint
to an App Icon Badge Number?
For example, when the iOS Setting Accessibility > VoiceOver
is turned On
, VoiceOver reads aloud items touched on screen. For the App Store and Mail icons, the following is read out aloud:
App Store icon, VoiceOver says: "App Store. 2 updates available. Double tap to open."
Mail icon, VoiceOver says: "Mail. 1 unread message. Double tap to open."
But, for the project I am working on, the VoiceOver read out is generic and not entirely helpful:
My App icon, VoiceOver says: "My App. 123 new items. Double tap to open."
The phrase "... new items" is too vague, not accurate, and I'm certain there must be a way to change this with a custom string to make it read better through setting an accessibilityLabel
, accessibilityHint
or something similar.
But how exactly in Swift code?
Many thanks.
Additional observation:
Using the Simulator Accessibility Inspector, it appears the VoiceOver values come from Label
- "My App" and Value
- "123 new items". So updated in the code I have tried setting the accessibilityValue
to something custom - "123 custom description.". But still no luck, VoiceOver continues to read "My App. 123 new items. Double tap to open."
Why isn't VoiceOver reading the custom badge value as expected?
Code:
The below method adds a red circle App Icon Badge Number to My App's icon:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let badgeCount: Int = 123
let application = UIApplication.sharedApplication()
if #available(iOS 8.0, *) {
//// iOS 8, iOS 9, iOS 10
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Badge], categories: nil))
} else {
//// iOS 7
}
application.applicationIconBadgeNumber = badgeCount
application.accessibilityValue = "123 custom description."
}
}
To access them, go to Settings > Accessibility > VoiceOver > VoiceOver Recognition. The Image Descriptions feature speaks descriptions of images shown in the app and on the browser. Screen Recognition automagically makes apps more accessible by recognizing items on the screen.
It appears this is an "Apple-only" feature as of now... source
Digging through API documentation, there doesn't seem to be any identifier that can set this for you, and I therefore think it's not publicly supported yet. It's likely been reported already, but reporting this as a request to Apple can never hurt.
Sorry this is probably not the answer you were hoping for! :/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With