Skip to main content

类:TouchBarLabel

类:TouchBarLabel

🌐 Class: TouchBarLabel

在触控栏为原生 macOS 应用创建标签

进程: 主进程
此类未从 'electron' 模块导出。它仅作为 Electron API 中其他方法的返回值提供。

new TouchBarLabel(options)

  • options 对象
    • label 字符串(可选)- 要显示的文本。
    • accessibilityLabel 字符串(可选)- 用于屏幕阅读器(如 VoiceOver)的按钮简短描述。
    • textColor 字符串(可选)- 文本的十六进制颜色,例如 #ABCDEF

在定义 accessibilityLabel 时,确保你已经考虑了 macOS 的最佳实践

🌐 When defining accessibilityLabel, ensure you have considered macOS best practices.

实例属性

🌐 Instance Properties

TouchBarLabel 实例上可用的属性如下:

🌐 The following properties are available on instances of TouchBarLabel:

touchBarLabel.label

string 表示标签当前的文本。更改此值会立即更新触控栏上的标签。

🌐 A string representing the label's current text. Changing this value immediately updates the label in the touch bar.

touchBarLabel.accessibilityLabel

一个 string,表示屏幕阅读器要读取的标签的描述。

🌐 A string representing the description of the label to be read by a screen reader.

touchBarLabel.textColor

一个表示标签当前文本颜色的 string 十六进制代码。更改此值会立即更新触控栏上的标签。

🌐 A string hex code representing the label's current text color. Changing this value immediately updates the label in the touch bar.