Skip to main content

类:TouchBarLabel

类:TouchBarLabel

¥Class: TouchBarLabel

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

¥Create a label in the touch bar for native macOS applications

进程:主进程
该类不是从 'electron' 模块导出的。它仅可用作 Electron API 中其他方法的返回值。

¥Process: Main
This class is not exported from the 'electron' module. It is only available as a return value of other methods in the Electron API.

new TouchBarLabel(options)

  • options 对象

    ¥options Object

    • label 字符串(可选) - 要显示的文本。

      ¥label string (optional) - Text to display.

    • accessibilityLabel 字符串(可选) - 供 VoiceOver 等屏幕阅读器使用的按钮的简短说明。

      ¥accessibilityLabel string (optional) - A short description of the button for use by screenreaders like VoiceOver.

    • textColor 字符串(可选) - 文本的十六进制颜色,即 #ABCDEF

      ¥textColor string (optional) - Hex color of text, i.e #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.