当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Swift Optional menuIndicator(_:)用法及代码示例


实例方法

menuIndicator(_:)

设置此视图中控件的菜单指示器可见性。

声明

func menuIndicator(_ visibility: Visibility) -> some View

参数

visibility

要应用的菜单指示器可见性。

详述

使用此修饰符覆盖此视图中控件的默认菜单指示器可见性。例如,下面的代码创建了一个没有指示器的菜单:


Menu {
    ForEach(history , id: \.self) { historyItem in
        Button(historyItem.title) {
            self.openURL(historyItem.url)
        }
    }
} label: {
    Label("Back", systemImage: "chevron.backward")
        .labelStyle(.iconOnly)
} primaryAction: {
    if let last = history.last {
        self.openURL(last.url)
    }
}
.menuIndicator(.hidden)

可用版本

iOS 15.0+, iPadOS 15.0+, macOS 12.0+, Mac Catalyst 15.0+

相关用法


注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 Optional menuIndicator(_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。