Search code examples
iosxamarin.iosaccessibilityxib

TextField announcing Label and AccessibilityLabel on Voice Over


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


Solution

  • 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