实例方法
touch
touchBar(content:)
设置 Touch Bar 显示的内容。
声明
func touchBar<Content>(content: () -> Content) -> some View where Content : View
返回值
包含触控栏内容的视图。
参数
content
由 Touch Bar 显示的视图集合。
详述
当您需要动态构建要在触控栏中显示的项目时,请使用 touchBar(_:)
。内容在适当时由触控栏显示,具体取决于焦点。
在下面的示例中,将四个按钮添加到 Touch Bar 内容结构,然后添加到 Touch Bar:
let touchBarItems = TouchBar(id: "myBarItems") {
Button("♣️", action: {})
Button("♥️", action: {})
Button("♠️", action: {})
Button("♦️", action: {})
}
TextField("TouchBar Demo", text: $placeholder)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.focusable()
.touchBar(touchBarItems)
可用版本
macOS 10.15+
相关用法
- Swift Never touchBar(_:)用法及代码示例
- Swift Never touchBarCustomizationLabel(_:)用法及代码示例
- Swift Never touchBarItemPrincipal(_:)用法及代码示例
- Swift Never touchBarItemPresence(_:)用法及代码示例
- Swift Never toggleStyle(_:)用法及代码示例
- Swift Never toolbar(id:content:)用法及代码示例
- Swift Never toolbar(content:)用法及代码示例
- Swift Never task(priority:_:)用法及代码示例
- Swift Never tag(_:)用法及代码示例
- Swift Never transformEffect(_:)用法及代码示例
- Swift Never textSelection(_:)用法及代码示例
- Swift Never task(id:priority:_:)用法及代码示例
- Swift Never transaction(_:)用法及代码示例
- Swift Never truncationMode(_:)用法及代码示例
- Swift Never textInputAutocapitalization(_:)用法及代码示例
- Swift Never textContentType(_:)用法及代码示例
- Swift Never tabItem(_:)用法及代码示例
- Swift Never tint(_:)用法及代码示例
- Swift Never pageCommand(value:in:step:)用法及代码示例
- Swift Never opacity(_:)用法及代码示例
- Swift Never colorMultiply(_:)用法及代码示例
- Swift Never accessibilityAction(action:label:)用法及代码示例
- Swift Never alert(isPresented:error:actions:message:)用法及代码示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:actions:)用法及代码示例
- Swift Never flipsForRightToLeftLayoutDirection(_:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 Never touchBar(content:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。