实例方法
touch
touchBarItemPresence(_:)
设置user-customized 视图的行为。
声明
func touchBarItemPresence(_ presence: TouchBarItemPresence) -> some View
返回值
说明此 Touch Bar 视图行为的特征。
参数
presence
允许的
TouchBarItemPresence
说明之一。
详述
使用touchBarItemPresence(_:)
定义用户自定义期间特定触控栏视图的可见性要求。
触控栏视图可能是:
-
.required
: 不允许用户删除。 -
.default
:在用户自定义之前默认显示,但可移除。 -
.optional
:默认情况下不可见,但可以通过自定义调色板添加。
每个TouchBarItemPresence
都必须使用一个字符串进行初始化,该字符串是该项目的全局唯一标识符。
在下面的示例中,除了 “Clubs” 项目之外,所有触控栏项目默认在触控栏中可见。它设置为.optional
,但可由用户配置:
TextField("TouchBar Demo", text: $placeholder)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.focusable()
.touchBar {
Button("♥️", action: selectHearts)
.touchBarItemPresence(.required("heartsKey"))
Button("♣️", action: selectClubs)
.touchBarItemPresence(.optional("clubsKey"))
Button("♠️", action: selectSpades)
.touchBarItemPresence(.required("spadesKey"))
Button("♦️", action: selectDiamonds)
.touchBarItemPresence(.required("diamondsKey"))
}
可用版本
macOS 10.15+
相关用法
- Swift Never touchBarItemPrincipal(_:)用法及代码示例
- 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 touchBarItemPresence(_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。