实例方法
touch
touchBarItemPrincipal(_:)
设置对该 Touch Bar 具有特殊意义的主要视图。
声明
func touchBarItemPrincipal(_ principal: Bool = true) -> some View
返回值
一个触控栏视图,其中一个元素位于触控栏行的中心。
参数
principal
一个布尔值,指示与其他视图相比是否在触控栏中突出显示此视图。
详述
使用 touchBarItemPrincipal(_:)
将视图指定为触控栏中的重要视图。目前,该视图将放置在行的中心。
下面的示例将最后一个按钮设置为 Touch Bar 视图的主要按钮。
let touchBarItems = TouchBar(id: "myBarItems") {
Button("♣️", action: {})
Button("♥️", action: {})
Button("♠️", action: {})
Button("♦️", action: {})
.touchBarItemPrincipal(true)
}
TextField("TouchBar Demo", text: $placeholder)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.focusable()
.touchBar(touchBarItems)
可用版本
macOS 10.15+
相关用法
- Swift Optional touchBarItemPresence(_:)用法及代码示例
- Swift Optional touchBar(_:)用法及代码示例
- Swift Optional touchBar(content:)用法及代码示例
- Swift Optional touchBarCustomizationLabel(_:)用法及代码示例
- Swift Optional toolbar(id:content:)用法及代码示例
- Swift Optional toolbar(content:)用法及代码示例
- Swift Optional toggleStyle(_:)用法及代码示例
- Swift Optional textSelection(_:)用法及代码示例
- Swift Optional tint(_:)用法及代码示例
- Swift Optional tabItem(_:)用法及代码示例
- Swift Optional textContentType(_:)用法及代码示例
- Swift Optional task(priority:_:)用法及代码示例
- Swift Optional transaction(_:)用法及代码示例
- Swift Optional textInputAutocapitalization(_:)用法及代码示例
- Swift Optional truncationMode(_:)用法及代码示例
- Swift Optional tag(_:)用法及代码示例
- Swift Optional transformEffect(_:)用法及代码示例
- Swift Optional task(id:priority:_:)用法及代码示例
- Swift Optional symbolVariant(_:)用法及代码示例
- Swift Optional popover(isPresented:attachmentAnchor:arrowEdge:content:)用法及代码示例
- Swift Optional mask(alignment:_:)用法及代码示例
- Swift Optional listSectionSeparatorTint(_:edges:)用法及代码示例
- Swift Optional badge(_:)用法及代码示例
- Swift Optional fullScreenCover(isPresented:onDismiss:content:)用法及代码示例
- Swift Optional keyboardType(_:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 Optional touchBarItemPrincipal(_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。