Monday, March 6, 2017

iOS how to know if Accessiblity Voiceover is running on device

The methods below will give info about whether accessibility is running

func UIAccessibilityIsVoiceOverRunning() -> Bool

You can use this function to customize your application’s UI specifically for VoiceOver users. For example, you might want UI elements that usually disappear quickly to persist onscreen for VoiceOver users. Note that you can also listen for the UIAccessibilityVoiceOverStatusChanged notification to find out when VoiceOver starts and stops, which is below.

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


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

On Android below API will help on this

AccessibilityManager am = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);
boolean isAccessibilityEnabled = am.isEnabled();
boolean isExploreByTouchEnabled = am.isTouchExplorationEnabled();

references:
https://developer.apple.com/reference/uikit/1615187-uiaccessibilityisvoiceoverrunnin


No comments:

Post a Comment