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 ↗Code shown on screen · 4 snippets
Graphic.swift
// Graphic.swift
open class BaseGraphic: InternalGraphic {
public var accessibilityHints: AccessibilityHints?
// ...
} AccessibilityHints.swift
// 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
// 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
// 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
Related sessions
-
14 min -
8 min -
5 min -
6 min -
8 min