带有 SidebarListStyle 的 SwiftUI 列表没有圆角?

SwiftUI List with SidebarListStyle does not have Rounded Corners?

我有一个 IssueListsSwiftUI


问题: 很简单,我有一个 List.listStyle(SidebarListStyle())NavigationView 里面并且角不是圆的 (见下图).


我的代码:

NavigationView {
    List {
        Label("Option", systemImage: "list.bullet.rectangle")
        Label("Option", systemImage: "tv")
        Label("Option", systemImage: "mail.stack")
    }
    .listStyle(SidebarListStyle())
    .navigationTitle("Options")
}

结果:


问题:如何实现圆角Standard iOS 14 List Design


非常感谢您的帮助!

为此你需要不同的风格

 List {
      Label("Option", systemImage: "list.bullet.rectangle")
      Label("Option", systemImage: "tv")
      Label("Option", systemImage: "mail.stack")
 }
 .listStyle(InsetGroupedListStyle())

更新: 使用条件列表样式

    NavigationView {
         List {
              Label("Option", systemImage: "list.bullet.rectangle")
              Label("Option", systemImage: "tv")
              Label("Option", systemImage: "mail.stack")
         }
         .sidebarStyle(if: UIDevice.current.userInterfaceIdiom == .pad)
         .navigationTitle("Options")
    }

和辅助扩展

extension List {
    @ViewBuilder
    func sidebarStyle(if flag: Bool) -> some View {
        if flag {
            self.listStyle(SidebarListStyle())
        } else {
            self.listStyle(InsetGroupedListStyle())
        }
    }
}

backup