7

I have UIAlertController with a message. I want the alert message accessibility label to be different than the alert message string.

How can I do that?

spassas
  • 4,778
  • 2
  • 31
  • 39
Tal Haham
  • 1,500
  • 12
  • 16

1 Answers1

-2

you can find each UIControl element using subviews array.

For example if you want to change accessibilityLabel of your UIAlertController you can do this:

let contentTitleForAlert = myAlertController.view.subviews[0].subviews[0].subviews[0].subviews[0].subviews[0].subviews[0]
        contentTitleForAlert.accessibilityLabel = "¡My text for accessibility label"

Using this way you can change other elements in the UIAlertController. For example:

let contentLabelForAlert = myalertController.view.subviews[0].subviews[0].subviews[0].subviews[0].subviews[0].subviews[1]
        contentLabelForAlert.accessibilityLabel = "Text for accessibilityLabel for main content in UIAlertController."
spassas
  • 4,778
  • 2
  • 31
  • 39
user2963707
  • 127
  • 1
  • 7