The "Accessibility Programming Guide For iOS" states:
Another way is to implement the isAccessibilityElement method of the UIAccessibility protocol in the implementation of your custom subclass. The following code snippet shows how to do this:
But when I am doing so, as in the following code:
class UITextLayerLabel : UIView, UIAccessibility {
XCode returns me this error:
[...] Use of undeclared type 'UIAccessibility'
What I am missing? A specific import? Is the protocol still available with iOS 10/XCode8?
As pointed out here, UIAccessibility is an informal protocol. For the difference between an informal protocol and a formal one, see here.
Basically, there is no type called UIAccessibility. Actually, UIView is already conforming to UIAccessibility. To make your custom view accessible, just override the properties and methods starting with accessibility.
So when do you need to implement UIAccessibility? As stated here,
You can use UIAccessibilityElement to provide information about an icon or text image is not automatically accessible because it does not inherit from UIView (or UIControl ). A view that contains such nonview items creates an instance of UIAccessibilityElement to represent each item that needs to be accessible.
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