Accessibility/ADA testing in iOS
You can design your apps in such a way that every one can use that app, including people with vision, learning or hearing disabilities through accessibility.
Accessibility is implemented on all standard UIKit views and controls so that assistive applications can present them to users with vision and hearing disabilities.
voice over is gesture based screen reader used in accessibility.
What are the advantages of Accessibility?
- It’s easier for functional and UI testing
- Everyone can use your app, including people with vision, learning or hearing disabilities.
How you test ADA in phone?
- Go to Settings -> Accessibility -> VoiceOver.
- Turn on VoiceOver
- Run your app.
- VoiceOver speaks the contents of the element
How to use app when Voice Over is on?
- Single-tap anywhere on the screen : voice over reads the data
- Single-swipe right: Move to next element on the screen
- Single-swipe left: Move to previous element on the screen.
- Double tap: To select the element.
How can you implement accessibility?
Add following code to your custom view to make it accessible.
view.isAccessibilityElement = true
view.accessibilityLabel = “ ”
view.accessibilityHint = “”
view.accessibilityTraits = UIAccessibilityTraits type
Five properties of Accessibility Attributes:
- Label: is the way to identify the control or view. Some examples are
Hi welcome to accessibility app
- Traits: These describe the element’s state, behaviour or usage. Some examples are
- Hint: Describes the action an element completes. For example:
Tap on button to change colour
- Frame: The frame of the element within the screen, in the format of a
CGRect. VoiceOver speaks the contents of the
- Value: The value of an element. For example, with a progress bar or a slider, the current value might read: 20 out of 25
How can you disable accessibility for a view?
false for the view to which you need to disable accessibility i.e
view.isAccessibilityElement = false .
Consider a situation, where you have custom view i.e tableview cell with labels. If you need to focus the whole cell instead of subviews of the cell then keep
isAccessibilityElement = true for cell.
isAccessibilityElement = true for child views or parent view according to your app requirement.
How to test accessibility in simulator?
don’t worry if you don’t have iPhone to test accessibility using voice over. You can test accessibility in simulator using
Steps to use Accessibility Inspector:
- Open accessibility inspector: Xcode -> Open Developer Dool -> Accessibility Inspector as shown in fig.1
- Run your app
Accessibility Inspectortarget to
simulatoras shown in fig2.
Inspected Element to find the focused element while the app is running in a simulator. Default accessibility inspector should look like this
5. You can press the
Play button in
navigation tab while the app is running in a simulator, let the Accessibility Inspector cycle through the app and voice over reads each elements. You can pause the audio at any time by pressing
6. You can use backward and forward button for focusing next and back element.
In the above app, I’ve taken two labels and a button. First label is header in this app. I need to describe that label as header so i set the value for
.header , for button as
.button and for normal text label as
Note: Voice over reads the text inside label, textfield or button with title automatically even though if your not using accessibilityLabel
To describe about Button with image or image view, you need to explicitly add accessibilityLabel for these views.
3 different tabs in Accessibility Inspector:
- Inspection Detail pane
- Inspector Audit
1. Inspection Detail pane:
It has everything you need to review and interact with the accessibility attributes in your app:
- Basic: Displays the attribute properties for the currently-highlighted element.
- Actions: Lets you perform actions like tapping a button or scrolling the view. Pressing the
Performbutton in this pane will perform the action on your target.
- Element: Displays the class, address and controller of the current item.
- Hierarchy: Shows the view hierarchy for the element, making it easier to understand complex views.
2. Inspector Audit:
It’s the most useful features due to its audit capability, which gives you warnings about accessibility problems within your app. To try out this feature, make sure your app is running in simulator. In the inspector, click the
Audit icon and then
How can you resolve these warnings?
- Click the
Suggest Fixesicon, which looks like question mark in a circle against each warning and the inspector will offer suggestions about how to fix the issue. You can act on these suggestions later.
- Click the
Eyeicon to take a snapshot of the app. This is useful for anyone who needs to create bug reports.
3. Additional Inspector Settings
It provides few other accessibility option to test your app.
- Invert colors: To preview what your interface looks like with dark and light theme. This is useful for people with light sensitivities, poor vision and colour blindness.
- If you want to change background colour of view or text in dark and light theme, create new
- If you want to change images in dark and light theme, create new
- Then add the following code to change appearance according to theme change.
2. Increase contrast: Contrast is a measure of the difference in perceived “luminance” or brightness between two colours.
3. Reduce transparency: Some apps use transparent and blurred backgrounds which can make text hard to read. It helps to test reduced transparency.
4. Reduce motion: That limits the amount and intensity of animations.
Use of reduce motion in swift:
When Reduce Motion is on, certain screen effects are disabled on your device, including:
- Screen transitions and effects use the dissolve effect instead of zoom or slide effects.
- Parallax effect where your wallpaper, apps, and alerts that move or shift slightly as you tilt your device are disabled.
- Animation and effects in certain apps are disabled.
5. Change font size: This is used to test dynamic font size changes for the users who prefer larger font sizes.
How can you test all these feature in phone?
- Go to Settings -> Accessibility
- Under accessibility -> Turn on setting which is required to test
- Run your app.
- Check the changes.
I hope you find this blog helpful. If you enjoyed it, feel free to hit the clap button below 👏 to help others find it! and follow me on Medium. Thanks for reading. ❤❤❤❤