Reading of Accessibility Label

I'm working on an eCommerce app. And there's a label that has the SKU/Product number.

When I am testing with VoiceOver for "4LN99" the voice over reads back "4 Liters N ninety nine". I'd like it to read back "Four L N Nine Nine".

Is there a property to modify that?

iOS 16

Thanks, Scott

Answered by Frameworks Engineer in 731632022

Hello, I'm glad you found a workaround. I also want to highlight the NSAttributedString key .accessibilitySpeechSpellOut, which tells VoiceOver to speak each character individually. You can set this on your view's .accessibilityAttributedLabel

Here are some documentation links which should help

https://developer.apple.com/documentation/foundation/nsattributedstring/key/3333285-accessibilityspeechspellout?changes=_2_8_2 https://developer.apple.com/documentation/objectivec/nsobject/2865944-accessibilityattributedlabel

I ended up doing this - taking that SKU/Product number - making it an array - then joining it back with a ',' so voice over pauses with each character. Not sure if this is the best practice - but it works for this case. So 4LN99 becomes 4,L,N,9,9

private func accessibilityProductCodeLabelText(_ productCode: String) -> String {

        let productCodeArray = Array(productCode)

        return productCodeArray.map { String($0) }.joined(separator: ",")

    }
Accepted Answer

Hello, I'm glad you found a workaround. I also want to highlight the NSAttributedString key .accessibilitySpeechSpellOut, which tells VoiceOver to speak each character individually. You can set this on your view's .accessibilityAttributedLabel

Here are some documentation links which should help

https://developer.apple.com/documentation/foundation/nsattributedstring/key/3333285-accessibilityspeechspellout?changes=_2_8_2 https://developer.apple.com/documentation/objectivec/nsobject/2865944-accessibilityattributedlabel

Reading of Accessibility Label
 
 
Q