类: TouchBarSegmentedControl
创建一个分段控件(按钮组),其中一个按钮具有选定状态
Process: Main
new TouchBarSegmentedControl(options)
实验功能
参数
对象segmentStyle
String (可选) - 分段的样式:automatic
- Default. The appearance of the segmented control is automatically determined based on the type of window in which the control is displayed and the position within the window. Maps toNSSegmentStyleAutomatic
.rounded
- The control is displayed using the rounded style. Maps toNSSegmentStyleRounded
.textured-rounded
- The control is displayed using the textured rounded style. Maps toNSSegmentStyleTexturedRounded
.round-rect
- The control is displayed using the round rect style. Maps toNSSegmentStyleRoundRect
.textured-square
- The control is displayed using the textured square style. Maps toNSSegmentStyleTexturedSquare
.capsule
- The control is displayed using the capsule style. Maps toNSSegmentStyleCapsule
.small-square
- The control is displayed using the small square style. Maps toNSSegmentStyleSmallSquare
.separated
- The segments in the control are displayed very close to each other but not touching. Maps toNSSegmentStyleSeparated
.
mode
String (可选) - 控件的选择模式:single
- Default. One item selected at a time, selecting one deselects the previously selected item. Maps toNSSegmentSwitchTrackingSelectOne
.multiple
- Multiple items can be selected at a time. Maps toNSSegmentSwitchTrackingSelectAny
.buttons
- Make the segments act as buttons, each segment can be pressed and released but never marked as active. Maps toNSSegmentSwitchTrackingMomentary
.
segments
SegmentedControlSegment[] - 被放到控件中的段的集合selectedIndex
Integer (optional) - 当前选中的段的下标, 这个值会在用户交互时自动更改 When the mode ismultiple
it will be the last selected item.change
Function (optional) - Called when the user selects a new segment.selectedIndex
Integer - 用户选中的段的下标。isSelected
Boolean - 当前段的选中状态
实例属性
以下为 TouchBarSegmentedControl
实例的可用属性:
touchBarSegmentedControl.segmentStyle
String
类型表示的当前段的样式. 更新这个值会立即触发更新当前段
touchBarSegmentedControl.segments
SegmentedControlSegment[]
类型表示的控件中段的集合 改变这个值会立刻刷新touch bar内的控件。 然而改变数组某元素内的嵌套属性不会刷新touch bar。
touchBarSegmentedControl.selectedIndex
Integer
类型表示的当前选中段 改变这个值会立即触发更新当前段 用户对触摸条的操作会自动更新这个值