0

I have a label in my app that the user should be able to tap on with VoiceOver enabled to have it speak the text of that label. However, I want it to always say something before it reads the label's text. I tried to set the accessibilityLabel via self.displayLabel.accessibilityLabel = "my text here" + self.displayLabel.text! but this results in it always being set to the label's original text value which is always changing in this app.

How can I add text to announce just before the label's content, ensuring it will always speak the label's current text contents?

Jordan H
  • 52,571
  • 37
  • 201
  • 351

1 Answers1

0

Override the accessibilityLabel property in the UILabel subclass to return whatever you'd like.

override var accessibilityLabel: String! {
    get {
        return "my text here" + "," + self.text!
    }
    set { }
}

You may want to post an announcement each time the text changes to inform VO users the value has changed.

Jordan H
  • 52,571
  • 37
  • 201
  • 351