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