无障碍设计:让 Apple Watch 服务每一个人
Accessibility by design: An Apple Watch for everyone
2021年6月9日
一句话判断
watchOS 8 的辅助触控(AssistiveTouch)证明了一件事:在手腕上不用手也能完整操作——如果你做的是 watchOS App,这是你必须适配的能力。
这场 Session 讲了什么
这个 Session 展示了 watchOS 8 在无障碍方面的重大更新,其中最重要的是 AssistiveTouch——让上肢运动障碍的用户可以通过手势(握拳、捏合)来操作 Apple Watch,不需要触碰屏幕。系统通过手表的陀螺仪和加速度计检测手臂和手腕的微动作,将它们映射为导航操作(上下滚动、选择、返回)。
Session 详细介绍了 AssistiveTouch 的技术实现:手势检测基于 Core Motion 的传感器融合数据,通过机器学习模型区分手势和日常手臂运动。开发者可以通过 UIAccessibility.isAssistiveTouchRunning 检测用户是否在使用这个模式,并据此调整 UI 布局(比如增大按钮间距以适配手势导航的精度)。
除了 AssistiveTouch,Session 还覆盖了 watchOS 的其他无障碍改进:VoiceOver 对复杂表盘的支持改进、更大的字体选项、以及新的「双指轻敲」手势作为辅助的交互方式。
值得深挖的点
AssistiveTouch 对 watchOS App 设计的影响。 传统的 watchOS App 设计假设用户能精确点击屏幕上的按钮。但在 AssistiveTouch 模式下,用户的操作粒度更粗——他们通过手势在控件之间「跳转」,而不是直接点击目标。这意味着你的 App 需要确保:1) 所有可交互元素都有正确的 isAccessibilityElement 标记;2) 元素的 accessibility 顺序符合逻辑(从左到右、从上到下);3) 关键操作的按钮足够大且间距足够宽。如果你使用 SwiftUI 的 accessibilityElement(children: .combine) 把多个元素组合成一个辅助功能元素,AssistiveTouch 用户就更容易导航到正确的位置。
WKAccessibility 的专用 API。 watchOS 有一些独特的辅助功能 API,比如 WKAccessibility.isAssistiveTouchRunning 和对手表表冠(Digital Crown)的辅助功能支持。你可以通过 Digital Crown 的 accessibilityIncrement / accessibilityDecrement 方法为使用辅助功能的用户提供精确的数值调整。另外,watchOS 的 VoiceOver 支持通过「双指轻敲」手势触发自定义操作,你可以通过 accessibilityCustomActions 注册这些操作。
代码片段
import SwiftUI
// 检测 AssistiveTouch 状态并调整 UI
struct WatchAppView: View {
@State private var isAssistiveTouchActive = false
var body: some View {
VStack(spacing: isAssistiveTouchActive ? 16 : 8) {
Button("开始锻炼") {
startWorkout()
}
.frame(maxWidth: .infinity, minHeight: 44) // 确保足够的点击区域
Button("查看历史") {
showHistory()
}
.frame(maxWidth: .infinity, minHeight: 44)
}
.onAppear {
isAssistiveTouchActive = WKAccessibility.isAssistiveTouchRunning
}
}
}
// 为复杂的手表界面提供辅助功能支持
struct ComplicationView: View {
let heartRate: Double
var body: some View {
ZStack {
Text("\(Int(heartRate))")
.font(.title2)
Text("BPM")
.font(.caption2)
}
// 不要只显示数字——为 VoiceOver 提供完整描述
.accessibilityElement(children: .ignore)
.accessibilityLabel("当前心率 \(Int(heartRate)) 次每分钟")
// 提供自定义操作让 AssistiveTouch 用户快速访问详情
.accessibilityCustomActions([
AccessibilityCustomAction(name: "查看心率详情") {
showHeartRateDetail()
return true
}
])
}
}
// 利用 Digital Crown 提供精确控制
struct ValuePickerView: View {
@State private var value = 50.0
@FocusState private var isFocused: Bool
var body: some View {
VStack {
Text("\(Int(value))%")
.font(.title)
Text("目标强度")
.font(.caption)
}
.focusable(true, onFocusChange: { focused in
isFocused = focused
})
.digitalCrownRotation($value, from: 0, through: 100, by: 1)
.accessibilityLabel("目标强度选择器")
.accessibilityValue("\(Int(value))%")
.accessibilityAdjustableAction { direction in
switch direction {
case .increment:
value = min(value + 5, 100)
case .decrement:
value = max(value - 5, 0)
@unknown default:
break
}
}
}
}
最佳实践
- watchOS App 的所有可交互元素最小尺寸应该是 44pt——这个尺寸不仅适合手指点击,也适合 AssistiveTouch 的手势导航
- 在真机上用 AssistiveTouch 测试你的 App,模拟器无法模拟手势检测
- VoiceOver 在 watchOS 上的使用场景和手机不同——用户通常在运动或手忙时使用,你的辅助功能描述要简洁
- 用
AccessibilityInspector的 watchOS 模式检查你的 App 是否有缺失的标签或无序的导航
还有什么值得关注
- watchOS 8 新增了「背景音」功能(系统设置中可开启),为注意力不集中的用户提供白噪音等环境声
- 全局辅助功能设置中可以调整「触控灵敏度」,影响手势检测的灵敏度
- Apple 的辅助功能设计指南专门有 watchOS 章节,涵盖了手表特有的交互模式