如何判断系统偏好设置中的 Voice Over 是否已打开?
有没有一种方法(最好向后兼容 Mac OS X 10.3)来判断系统偏好设置中是否激活了“Voice Over”?
Is there an way, ideally backwards compatible to Mac OS X 10.3, to tell if "Voice Over" is activated in System Preferences?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Swift 4 中的解决方案如下:
此外,要在 macOS 上使用 VoiceOver 进行文本通知,请执行以下操作:
Solution in Swift 4 is as follows:
Furthermore, to make a text announcement with VoiceOver on macOS, do the following:
这似乎存储在通用访问的首选项文件中。 应用程序标识符是“com.apple.universalaccess”,包含 VoiceOver 是否打开或关闭标志的键是“voiceOverOnOffKey”。 您应该能够使用 CFPreferences API 检索此信息,如下所示:
This appears to be stored in a preferences file for Universal Access. The app identifier is "com.apple.universalaccess" and the key containing the flag for whether VoiceOver is on or off is "voiceOverOnOffKey". You should be able to retrieve this using the CFPreferences API, something looking like:
如果有人有同样的问题,很高兴知道现在可以通过方便的界面访问 Voice Over 状态:
If anyone has the same question, it could be good to know, that Voice Over status is accessible via convenient interface now:
基于 Petes 的出色回答,我创建了这个 Swift 4.2 解决方案,我发现它更容易阅读。 我还认为在这种情况下使用计算属性而不是函数更方便。
一般来说,VoiceOver 和辅助功能是非常重要的主题,但令人遗憾的是,苹果文档的缺乏,尤其是针对 macOS 的文档,使得开发人员很难正确实现它。
Based on Petes excellent answer I’ve created this Swift 4.2 solution, which I find much easier to read. I also think it’s more handy to use a computed property in this case instead of a function.
VoiceOver and Accessibility in general are very important topics and it is sad that the lack of Apples documentation especially for macOS makes it so hard for developers to implement it properly.