Creating an Accessible Reading Experience

Written by Stefan Herold

Description: The styling and layout of text is a hallmark feature of an outstanding reading experience. Technologies such as CoreText and TextKit give you the tools you need to create a great text layout. Learn how to make an equally great accessible experience for VoiceOver by adopting the accessibility reading content protocol, adding automatic page turning, and customizing speech output.

  • For custom views set isAccessibilityElement = true
  • Enable Accessible Text Content by adopting UIAccessibilityReadingContent
    • In accessibilityLineNumber(for point: CGPoint) -> Int use hit testing to identify subviews
    • In accessibilityContent(forLineNumber: Int) -> String? return the accessibilityLabel for the subview matching line number
    • In accessibilityFrame(forLineNumber: Int) -> CGRect return the accessibilityFrame for the subview matching line number
    • In accessibilityPageContent() -> String? return the concatenated accessibility labels for all subviews
  • Enable Automatic Page Turn by
    • setting view.accessibilityTraits = UIAccessibilityTraits.causePageTurn on your page view
    • implementing accessibilityScroll(_ direction: UIAccessibilityScrollDirection) -> Bool (lets voice over turn pages)
  • Customizing Speech by adopting the protocol UIAccessibilityReadingContent
    • customize language by setting NSAttributedString.Key.accessibilitySpeechLanguage
    • customize pitch by setting NSAttributedString.Key.accessibilitySpeechPitch

This note was originally published at github.com/Blackjacx/WWDC.

Missing anything? Corrections? Contributions are welcome 😃

Written by

Stefan Herold

Stefan Herold

iOS Developer a.d. 2009 • iOS / OSX Enthusiast • WWDC19 • Past: flinc, Deutsche Telekom, NOLTE&LAUTH • Passionate Mountainbiker