skip to Main Content

I’ve created a custom button and set two images, one is for normal, and the other is for the selected mode. But the voice-over always says the normal image name text when the button is not selected. I’ve tried a lot but could not disable it.

When I disable the button imageView accessibility it is not working.

button.imageView?.isAccessibilityElement = false

When I disable the button accessibility, the voice-over is not working in accessibility mode.

button.isAccessibilityElement = false

If I remove the ‘.normal’ mode image then it works, but normal mode image functionality is not considered/worked there. I’m surfing a lot. Help anyone and thanks in advance.

Code:

self.setImage(UIImage.init(named: imageName1), for: .normal)
self.setImage(UIImage.init(named: imageName1), for: .selected)

2

Answers


  1. Simply, It is not possible. You can use an accessibility label instead.

    button1.imageView?.accessibilityLabel = "Radio button deselected"
    
    Login or Signup to reply.
  2. You have to set button accessibilityLabel as empty string.

    button1.accessibilityLabel = ""
    

    VoiceOver will stop saying image name for any of the state.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search