Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding VoiceOver Accessibility compatibility. #213

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

awall1
Copy link

@awall1 awall1 commented Nov 16, 2017

This is in reference to: #212

I've added some generic Accessibility Labels to the content view for each type. If there is a specific title or subtitle, it will speak that text instead.

Known issue: After HUD is dismissed, the VoiceOver will focus on the first UI element directly behind it (typically right in the center).

@awall1 awall1 mentioned this pull request Nov 16, 2017
@PGLongo
Copy link
Collaborator

PGLongo commented Nov 16, 2017

Hi, thanks for the PR. Can you upload some screens about what changes with this feature?

@awall1
Copy link
Author

awall1 commented Nov 27, 2017

@PGLongo funny thing is, there are no visual changes. Only someone using VoiceOver (a blind person) will be able to hear the difference. VoiceOver is an accessibility tool built into iOS that will read out loud what each element on a screen is.
Whenever the HUD is shown, VoiceOver will speak whatever is in the accessibilityLabel.
Below are what I've set the accessibilityLabel to for each HUD type:

        switch content {
        case .success:
            self.accessibilityLabel = "Success!"
        case .error:
            self.accessibilityLabel = "Error!"
        case .image(_),
             .rotatingImage(_):
            self.accessibilityLabel = "Image"
        case .label(let title):
            guard let label = title else { break }
            self.accessibilityLabel = label
        case .labeledSuccess(let title, let subtitle),
             .labeledError(let title, let subtitle),
             .labeledProgress(let title, let subtitle),
             .labeledImage(_, let title, let subtitle),
             .labeledRotatingImage(_, let title, let subtitle):
            guard title != nil || subtitle != nil else { break }
            self.accessibilityLabel = (title ?? "") + "\n" + (subtitle ?? "")
        default:
            self.accessibilityLabel = "Please wait."
        }

The labels aren't ideal in that they don't always present with perfect context (i.e. "Image" tells me nothing), but it's at least a start.

Copy link
Collaborator

@PGLongo PGLongo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setAccessibilityProperties shouldn't be an UIView extension. It's correct and useful only in Hud.swift

Speakus added a commit to Speakus/PKHUD that referenced this pull request Apr 20, 2018
@Speakus Speakus mentioned this pull request Apr 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants