I have a UIButton that is sometimes blank (no text or image). When it is blank, I want VoiceOver to skip over it. I've tried the following things, but none of them do the job -- the button still gets highlighted as the user swipes through the views:
Set the button and all of its subviews' .accessibilityTraits to UIAcessibilityTraitNotEnabled. This prevents VoiceOver from saying anything when the button is selected, but it still allows the button to be selectable by VoiceOver.
Disable the button (I verified that the button is disabled in the Debug View Hierarchy view). The button remains selectable by VoiceOver.
Anybody know how to make VoiceOver skip over / ignore a UIButton completely?
Try the following:
someButton.isAccessibilityElement = NO;
This tells the button that it isn't an accessible element. This should prevent voice-over from stopping at the button.
Swift 4
This didn't work for me:
someButton.isAccessibilityElement = false
This did work:
someButton.accessibilityElementsHidden = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With