Developer

Pro tip: Integrate system user accessibility preferences into iOS 7 and iOS 8 apps

Learn how to make your iOS 7 and iOS 8 apps more accessible to a wider audience by tapping into users' preferences.

accessibilityhero.png

iOS includes accessibility preferences that help users create a custom experience that meets their needs. While iOS and the Apple apps that are in the App Store conform to these preferences, it's up to developers to ensure their apps meet users' expectations and needs.

Here's a look at some of the APIs to check for user preferences, along with details about how to use them in your apps.

Reducing motion and using the Accessibility API in UIKit

iOS 7 includes motion throughout the user experience, but in the iOS 8 SDK, you can detect a user's preference for reducing motion so you can reduce any motion in your own user interface (UI). Apps push and pull their way into and out of existence when opening them from the Home screen. Things slide, tilt, and animate when moving things around or tilting your device. iOS 7 and 8 are lively to say the least. Some of this liveliness can present a usability nightmare.

Fortunately, Apple includes great accessibility features in iOS that makes the user experience better. One of these settings is called Reduce Motion and can be found via Settings | General | Accessibility | Reduce Motion. Enable this setting, and you will see that the UI elements parallax, pushing in and out, and the effects of icons and alerts are significantly changed to subtle fade effects without any animation or motion.

When developing iOS apps, you might be inclined to add parallax effects, motion in tables, and more. While that's fine, you should ensure that you're checking for this preference to ensure that you're providing a consistent user experience for all users.

Here's sample code showing how you would perform the check in Objective-C when animating in objects.

CGFloat animationDuration;

if (UIAccessibilityIsReduceMotionEnabled()) {
    animationDuration = 0.0f;
} else {
    animationDuration = 0.33f;
}

CGRect newFrame = self.button.bounds; 
newFrame.y = 200.0f;
newFrame.x = 300.0f;

[UIView animateWithDuration:animationDuration animations:^{
       self.button.frame = newFrame;
}];

In this example, we have a UIImageView that we are animating into view. Before doing the animation, we'll check to see if the user has the option enabled for Reduce Motion by calling the function UIAccessibilityIsReduceMotionEnabled() that is included in UIKit. With this if statement, we'll know if this option is enabled and can set the animation duration appropriately so that when we perform the animation, the button will simply snap to the new frame instead of animating into view.

This very simple example shows the point that you should be changing the behavior of your animations based on the user's needs. Reducing motion is not the only user preference API that you can tap into — below is the full list that is supported by UIKit.

Other accessibility preference APIs

  • UIAccessibilityIsVoiceOverRunning() returns a BOOL value: YES if running, NO otherwise. Use this check to see if Voice Over (the screen reader built into iOS) is running; if it is running, you might want to delay additional UI sounds, or you might want to persist UI elements longer if they usually disappear quickly.
  • UIAccessibilityIsClosedCaptioningEnabled() returns a BOOL value: YES if enabled, NO otherwise. Use this check if your application utilizes videos or photos, and you'd like to provide captions to users that have this option enabled in device Settings.
  • UIAccessibilityIsGuidedAccessEnabled() returns a BOOL value: YES if enabled, NO otherwise. Use this check to see if Guided Access is enabled for the current user; if it is, you may wish to hide certain administrative controls inside of your application. Guided Access is designed to limit user interaction with certain elements in an application, including limiting the ability to quit apps.
  • UIAccessibilityIsInvertColorsEnabled() returns a BOOL value: YES if enabled, NO otherwise. Use this setting to see if the user has inverted the colors on the device.
  • UIAccessibilityIsMonoAudioEnabled() returns a BOOL value: YES if enabled, NO otherwise. Use this setting if you're developing an app that uses the device or headset speakers. Ensuring that you're not playing left/right-only audio will be beneficial to the user. You can find out if they have this option enabled by calling this function.

Adding your own preferences

UIKit includes a lot of accessibility preference functionality that you can extend into your applications, though this might not always be enough, and you may want to add your own preferences. The important thing to remember is that accessibility is not a "one size fits all" type of methodology when it comes to developing mobile applications — you should always look at your user's needs.

Additional resources for accessibility in iOS and OS X

About Cory Bohon

Cory Bohon is an indie developer specializing in iOS and OS X development. He runs a software company called Cocoa App and is also a developer at MartianCraft. He was introduced to technology at an early age and has been writing about his favorite te...

Editor's Picks

Free Newsletters, In your Inbox