Arash
Arash

Reputation: 1316

iOS Voiceover status

I am trying to add accessibility features to an iOS app that has already been developed.

There are a couple of UI features (e.g. buttons) that I like them to show up if the VoiceOver option in the accessibility menu of the iPhone settings is on and do not show up if the voiceover is off.

Is there a way to check whether the voiceover option is on or not?

Upvotes: 75

Views: 23635

Answers (4)

Lucas P.
Lucas P.

Reputation: 4532

For Swift 4.2 and newer versions, you can check the following boolean provided by UIKit:

UIAccessibility.isVoiceOverRunning

Upvotes: 18

XLE_22
XLE_22

Reputation: 5671

As a supplement to all the previous correct answers, since iOS11 and according to this Accessibility options recap, the new notification name to be used is :

  • UIAccessibilityVoiceOverStatusDidChange (SWIFT < 4.2).
  • UIAccessibilityVoiceOverStatusDidChangeNotification (ObjC).

... while UIAccessibilityVoiceOverStatusChanged is deprecated.

EDIT for SWIFT 4.2 ==> UIAccessibility.voiceOverStatusDidChangeNotification

Upvotes: 3

David Dunham
David Dunham

Reputation: 8329

BOOL UIAccessibilityIsVoiceOverRunning();

Upvotes: 125

Rakesh iOS Dev
Rakesh iOS Dev

Reputation: 955

In ViewDIdLoad

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(voiceOverStatusChanged)
                                             name:UIAccessibilityVoiceOverStatusChanged
                                           object:nil];


- (void)voiceOverStatusChanged
{
    if(!UIAccessibilityIsVoiceOverRunning())
    {
        //do your changes
    }
}

Upvotes: 36

Related Questions