Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2020 Accessibility & InclusionSwift

WWDC20 · 15 min · Accessibility & Inclusion / Swift

Swan’s Quest, Chapter 1: Voices in the dark

Swift Playgrounds presents "Swan’s Quest,” an interactive adventure in four chapters for all ages. In this chapter, our Hero must navigate a dark cave — and the only way to light the torches is to make them accessible. Learn about VoiceOver and write interesting audio descriptions. You just might help our Hero find their way out… and get a clue for the next challenge. Swan’s Quest was created for Swift Playgrounds on iPad and Mac, combining frameworks and resources which power the educational experiences in many of our playgrounds, including Sonic Workshop, Sensor Arcade, and Augmented Reality. To learn more about building your own playgrounds, be sure to watch "Create Swift Playgrounds content for iPad and Mac". And don’t forget to stop by the Developer Forums and let us know what you thought of Swan’s Quest.

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 4 snippets

Graphic.swift swift · at 12:21 ↗
//  Graphic.swift

open class BaseGraphic: InternalGraphic {
   
    public var accessibilityHints: AccessibilityHints?

    // ...
}
AccessibilityHints.swift swift · at 12:32 ↗
//  AccessibilityHints.swift

public struct AccessibilityHints: Codable {

   /// Indicates a graphic should be treated as a UIAccessibilityElement by VoiceOver.
   public var makeAccessibilityElement: Bool = false
    
   /// Label spoken by VoiceOver for the accessible graphic (a localized character name).
   public var accessibilityLabel: String?

   // ... 

}
Make an Accessible Graphic swift · at 12:45 ↗
// Make an Accessible Graphic

import SPCCore
import SPCAccessibility

let hints = AccessibilityHints(makeAccessibilityElement: true, 
                               accessibilityLabel: "Activate button to start the party")

let graphic = Graphic(name: "Let's get it Started")
graphic.accessibilityHints = hints
Activating torch1 and torch2 swift · at 13:51 ↗
// activate torch1 and torch2

cave.torch1.accessibilityHints = AccessibilityHints(makeAccessibilityElement: true, 
        accessibilityLabel: "Torch next to a stairwell, where dripping water can be heard.")
cave.torch2.accessibilityHints = AccessibilityHints(makeAccessibilityElement: true, 
        accessibilityLabel: "Right before the edge of the platform—be careful!")

Resources