【问题标题】:How to hide the navigation button when using NavigationSplitView?使用NavigationSplitView时如何隐藏导航按钮?
【发布时间】:2022-12-04 22:52:19
【问题描述】:

现在 NavigationView 已被弃用,我尝试使用 NavigationSplitView。但是我无法隐藏导航切换按钮,也无法自定义标题栏(我想保留标题并添加过滤器按钮)。

My app screenshot

我只想像 Mail.app 一样实现

Mail.app screenshot

Some other app screenshot

代码 sn-p 如下:

// ...
var body: some View {
    NavigationSplitView(columnVisibility: $columnVisibility) {
        DirectoryList(selection: $selectionDir)
    } content: {
        PaperList(selection: $selectionPaper)
            .navigationTitle(Text("Papers"))
            .toolbar {
                HStack {
                    Button {
                        // something todo
                    } label: {
                        Label("Experience", systemImage: "wand.and.stars")
                    }
                }
                .frame(maxWidth: .infinity, alignment: .trailing)
            }
    } detail: {
        Editor(selectionPaper?.name ?? "")
    }
}
// ...

【问题讨论】:

    标签: swift swiftui


    【解决方案1】:

    你可以尝试使用isToggleButtonHidden

    NavigationSplitView(columnVisibility: $columnVisibility, isToggleButtonHidden: true) {
        // Your content here
    }
    

    【讨论】:

      猜你喜欢
      • 2014-01-30
      • 2012-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-21
      相关资源
      最近更新 更多