0

When setting the UILabel's AccessibilityLabel, the AccessibilityLabel is announced on voice over instead of the Text. However, when setting the UITextField's AccessibilityLabel, the AccessibilityLabel AND the Text are announced on Voice Over.

How can I overwrite the UITextField.Text on Voice Over announcement? I do not want to announce the Text, I need to announce something else because I the texts are dates, for example, 01/10/2021, and I want to announce "January 10th, 2021" instead. When I set the AccessibilityLabel it announces "January 10th, 2021 01/10/2021".

Marcelo
  • 217
  • 1
  • 2
  • 11
  • 1
    A `UITextField` is just an input field. According to WCAG 4.1.2, the screen reader should announce the name, role, and value. You are hearing the name via `AccessibilityLabel` and you are hearing the value via the `Text`. So what you're asking is that you want an input field's label read but not the input field's value. That would be a bad thing. But I understand you wanting the value to be read differently than the literal value. A screen reader user has many options for how dates are read and the choice should be left up to them. – slugolicious Nov 09 '21 at 20:32
  • Thank you for the information, date reading is only one of the cases. Some other TextFields have a "/mo" that we need to be announced as "per month" when using voice over instead of "slash mo". There is also some other cases that are really specific and per product decision, we need to announce something else than what is being displayed. – Marcelo Nov 09 '21 at 21:08

1 Answers1

1

Look at the following definitions

  • accessibilityLabel

    A succinct label in a localized string that identifies the accessibility element.

  • accessibilityHint

    A localized string that contains a brief description of the result of performing an action on the accessibility element.

  • AccessibilityValue

    A string that represents the current value of the accessibility element.

Try to set the accessibilityHint and accessibilityLabel as empty string and set AccessibilityValue as what you want .

textfield.AccessibilityLabel = "";
textfield.AccessibilityHint = "";
textfield.AccessibilityValue = "the string you want ";

Refer to

Override VoiceOver message in UITextField - iOS Accessibilty

change UITextField accessibility description

ColeX
  • 14,062
  • 5
  • 43
  • 240