You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Swift中Accessibility Label用逗号分隔无朗读停顿如何解决?

iOS VoiceOver 无障碍标签添加停顿的解决方案
  • 直接用逗号、点号或换行没法让VoiceOver产生有效停顿,因为这些符号不会被解析成语音停顿指令,得用官方支持的两种方法:

方法1:使用带属性的无障碍标签(推荐)

通过accessibilityAttributedLabel结合UIAccessibilitySpeechAttributePause属性,能精确控制停顿时长:

let count = 7
let baseText = "User count updated: \(count)"
let attributedLabel = NSMutableAttributedString(string: baseText)
// 在文本末尾添加0.5秒的停顿,时长可按需调整(单位:秒)
attributedLabel.addAttribute(
    .accessibilitySpeechPause,
    value: 0.5,
    range: NSRange(location: baseText.count, length: 0)
)
labelview.accessibilityAttributedLabel = attributedLabel

方法2:使用VoiceOver特殊语音标记

直接在字符串里插入[[slnc X]]标记(X是停顿毫秒数),VoiceOver会识别并执行停顿:

let count = 7
labelview.accessibilityLabel = "User count updated: \(count)[[slnc 500]]"

补充说明

普通标点、换行符属于文本内容,VoiceOver会按常规语音规则处理,不会触发自定义停顿,所以你之前试的连续逗号、点号、换行都达不到预期效果。

内容的提问来源于stack exchange,提问作者Srivalli Velusamy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 08:27:05