Creating an Accessible Reading Experience
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 theaccessibilityLabel
for the subview matching line number - In
accessibilityFrame(forLineNumber: Int) -> CGRect
return theaccessibilityFrame
for the subview matching line number - In
accessibilityPageContent() -> String?
return the concatenated accessibility labels for all subviews
- In
- Enable Automatic Page Turn by
- setting
view.accessibilityTraits = UIAccessibilityTraits.causePageTurn
on your page view - implementing
accessibilityScroll(_ direction: UIAccessibilityScrollDirection) -> Bool
(lets voice over turn pages)
- setting
- Customizing Speech by adopting the protocol
UIAccessibilityReadingContent
- customize language by setting
NSAttributedString.Key.accessibilitySpeechLanguage
- customize pitch by setting
NSAttributedString.Key.accessibilitySpeechPitch
- customize language by setting
This note was originally published at github.com/Blackjacx/WWDC.