Test Accessibility Actions On A Custom SwiftUI Control
A custom control can have a perfect accessibility label and still be unusable. If the only way to change it is dragging a dot, a person who hears that label has learned the control’s name without gaining access to its purpose.
WWDC26’s Refine accessibility for custom controls frames the problem around purpose, value, actions, and feedback. Let’s apply that to a photo editor with a two-axis adjustment pad, then test what its actions actually do.
Name the effect of each action
Our horizontal axis changes warmth and the vertical axis changes exposure. “Move left” is a geometric description; “Cooler” describes the edit. The latter is more useful when someone is operating the control without relying on its visual position.
A single adjustable action has increment and decrement directions. For two independent dimensions, named custom actions make each operation explicit. The sample also exposes a reset action so the user can return to a known state without reversing a long sequence of edits.
The command model owns the bounds. Touch and accessibility input both change the same value:
import SwiftUI
struct PhotoAdjustment: Equatable {
enum Command { case brighter, darker, warmer, cooler, reset }
private(set) var exposureTenths = 0
private(set) var warmth = 0
mutating func apply(_ command: Command) {
switch command {
case .brighter: exposureTenths = min(20, exposureTenths + 1)
case .darker: exposureTenths = max(-20, exposureTenths - 1)
case .warmer: warmth = min(100, warmth + 10)
case .cooler: warmth = max(-100, warmth - 10)
case .reset:
exposureTenths = 0
warmth = 0
}
}
mutating func setPosition(x: Double, y: Double) {
guard x.isFinite, y.isFinite else { return }
warmth = Int((min(1, max(0, x)) * 200 - 100).rounded())
exposureTenths = Int(((1 - min(1, max(0, y))) * 40 - 20).rounded())
}
}
struct AdjustmentPad: View {
@Binding var adjustment: PhotoAdjustment
var body: some View {
GeometryReader { geometry in
ZStack {
RoundedRectangle(cornerRadius: 16).fill(.quaternary)
Circle().fill(.tint).frame(width: 24, height: 24)
.position(
x: CGFloat(adjustment.warmth + 100) / 200 * geometry.size.width,
y: (1 - CGFloat(adjustment.exposureTenths + 20) / 40) * geometry.size.height
)
}
.contentShape(Rectangle())
.gesture(
DragGesture(minimumDistance: 0).onChanged { value in
guard geometry.size.width > 0, geometry.size.height > 0 else { return }
adjustment.setPosition(
x: value.location.x / geometry.size.width,
y: value.location.y / geometry.size.height
)
})
}
.frame(minHeight: 160)
.accessibilityElement(children: .ignore)
.accessibilityLabel("Photo adjustments")
.accessibilityValue(
"Exposure \(Double(adjustment.exposureTenths) / 10) EV, warmth \(adjustment.warmth)"
)
.accessibilityAction(named: Text("Brighter")) { adjustment.apply(.brighter) }
.accessibilityAction(named: Text("Darker")) { adjustment.apply(.darker) }
.accessibilityAction(named: Text("Warmer")) { adjustment.apply(.warmer) }
.accessibilityAction(named: Text("Cooler")) { adjustment.apply(.cooler) }
.accessibilityAction(named: Text("Reset adjustments")) { adjustment.apply(.reset) }
}
}
Exposure is stored in tenths to make the discrete commands predictable. Warmth is an example editor scale from -100 to 100, not a claim about color temperature in kelvin. The rendering pipeline would map these model values to the photo adjustments it supports.
The accessibility value includes both dimensions. Changing warmth must not leave VoiceOver describing only exposure, and resetting must update the spoken state as well as the dot.
Avoid duplicate fragments
The pad is one accessibility element with its visual children ignored. Otherwise, decorative shapes can become extra stops that describe implementation details rather than useful actions.
That grouping decision is specific to this pad. Do not hide a whole container’s children if they include independent buttons or information the user still needs. A toolbar with several commands is not automatically one control merely because its background is drawn as one rounded rectangle.
The sample uses established SwiftUI accessibility modifiers; it does not require a newly introduced iOS 27 control API. The WWDC26 session is useful here because of the interaction review it encourages, not because every lesson requires the newest deployment target.
Test actions at the boundaries
A code fixture can send fifty “Brighter” commands and verify that exposure stops at its upper bound. Run the reverse direction past the lower bound, reset, and confirm both dimensions return to zero. Check the touch mapping at the center and reject nonfinite coordinates before converting to integers.
Those checks confirm the model. They do not prove that the actions are discoverable or that a screen reader announces the right value after each action.
For the actual view, move accessibility focus onto the pad and check its label, current value, and available actions. Invoke every action. At a boundary, the model should remain stable; the interface should not imply that more range is available when nothing changes.
Then test with Switch Control and Voice Control as appropriate for the app. Make the same editing operations available through ordinary controls or keyboard commands for users who do not use touch gestures. The custom pad should be a convenient input surface, not the only route to the feature.
Listen to feedback instead of counting announcements
A rapidly changing value can overwhelm speech. Do not post an announcement for every drag sample just because the code can. Start by checking the feedback the accessibility value and chosen interaction already provide.
If the product needs additional feedback during direct manipulation, design a measured update policy and test it by listening. Keep meaningful changes understandable without continuously interrupting the user. A fixed delay copied from a demo is a starting experiment, not proof that the experience is right for this control.
September 2026 review: the complete view compiles with Swift 6.4 and Xcode 27, and executable model checks passed for command limits, reset, center mapping, and invalid input. VoiceOver, Switch Control, Voice Control, and keyboard behavior have not been device-tested for this sample.
The useful accessibility test has two parts: can someone discover the operation, and does invoking it produce the same valid edit as other input methods? A label answers only the first part of the first question.