Mark accessibility elements as "ignored" by Accesibility Inspector

1.3k Views Asked by At

I am testing my iOS application in terms of accessibility and I am trying to reduce as many warnings as possible. Some elements, like images, I want to omit from the Voice Over, so I mark them as not accessible. However, in the Accessibility Inspector, I get the warning

"Potentially inaccessible text" - even though it is an image marked as not accessible.

Is there a way to mark some elements as "ignored" for the Accessibility Inspector such that they are not reported anymore?

Accessibility Inspector printscreen: Accessibility Inspector printscreen

2

There are 2 best solutions below

0
On BEST ANSWER

It is not an answer itself, but maybe you could do something similar. I had the same issue. Setting the isAccessibilityElement to false should've done the trick but it seems to be a bug. In my case what solved the issue was to make the container of the image an accessibility element and the warning disappeared. Doing this the inner items are going to be ignored and I think the accessibility inspector is not going to take that into account. But the isAccessibilityElement should do the same but for some reason it isn't. ;)

1
On

If you wanted to mark an image as decorative, create a decorative image instead of masking the image.

https://developer.apple.com/documentation/swiftui/image/init(decorative:bundle:)

However, in this case, you have an image with text in it. That is no longer an image by itself, it is an image with at least one letter in it, and the audit is saying if there's a letter in it then all users might need to know what this is. Maybe a logo, maybe an "i" information icon. If this text is indeed not intended to add anything meaningful to the page (you could delete it and the content would still have the same meaning, like an image of a freeway with an exit sign with the text "Sunset Blvd", just to add a visual to body content about living in L.A. with traffic) then make it decorative with the above code.

Just make sure this is intended to be decorative before you do this.