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