100 Days of SwiftUI
2026-07-28
Project 15, part 2
Revisiting old projects to add accessibility features
Handling voice input in SwiftUI
Normally, a user using voice input would say “Tap John Fitzgerald Kennedy” if the button label was the only option. Adding .accessibilityInputLabels() means iOS will respond to more than just the label.
Button("John Fitzgerald Kennedy") {
print("Button tapped")
}
.accessibilityInputLabels(["John Fitzgerald Kennedy", "Kennedy", "JFK"])Fixing Guess the Flag
Since Guess the Flag needs to not say the name of the flag, give a short description of each one and that will be read by VoiceOver


let labels = [
"Estonia": "Flag with three horizontal stripes. Top stripe blue, middle stripe black, bottom stripe white.",
"France": "Flag with three vertical stripes. Left stripe blue, middle stripe white, right stripe red.",
"Germany": "Flag with three horizontal stripes. Top stripe black, middle stripe red, bottom stripe gold.",
"Ireland": "Flag with three vertical stripes. Left stripe green, middle stripe white, right stripe orange.",
"Italy": "Flag with three vertical stripes. Left stripe green, middle stripe white, right stripe red.",
"Nigeria": "Flag with three vertical stripes. Left stripe green, middle stripe white, right stripe green.",
"Poland": "Flag with two horizontal stripes. Top stripe white, bottom stripe red.",
"Spain": "Flag with three horizontal stripes. Top thin stripe red, middle thick stripe gold with a crest on the left, bottom thin stripe red.",
"UK": "Flag with overlapping red and white crosses, both straight and diagonally, on a blue background.",
"Ukraine": "Flag with two horizontal stripes. Top stripe blue, bottom stripe yellow.",
"US": "Flag with many red and white stripes, with white stars on a blue background in the top-left corner."
]Fixing Word Scramble
Again, a straightforward addition to the scoring table
HStack {
Image(systemName: "\(word.count).circle")
Text(word)
}
.accessibilityElement()
.accessibilityLabel("\(word), \(word.count) letters")Fixing Bookworm
Ratings panel is problematic, especially since it was designed to be reusable.
In the RatingsView, add this to the HStack
.accessibilityElement()
.accessibilityLabel(label)
.accessibilityValue(rating == 1 ? "1 star" : "\(rating) stars")
.accessibilityAdjustableAction { direction in
switch direction {
case .increment:
if rating < maximumRating { rating += 1 }
case .decrement:
if rating > 1 { rating -= 1 }
default:
break
}
}