實例方法
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(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。