防止MacOS杆有侧边栏

发布于 2025-02-09 18:20:03 字数 1029 浏览 1 评论 0原文

默认情况下,将第一个列表添加到视图中似乎已设置为侧边栏。即使您不专门调用.listStyle(sideBarlistStyle())

您在视图上设置的列表是否有任何方法(即使是第一个视图)未设置为侧边栏? Apple的文档没有任何迹象,我试图为列表无法使用的任何样式。

因此,而不是像这样的列表:

”在此处输入图像描述“

应该看起来像:

“在此处输入图像说明”

编辑:

是的,代码。任何简单的代码都会做。

struct ContentView: View {
    var body: some View {
        List {
                NavigationLink(
                    destination: TextEView(),
                ) {
                    Text("One")
                }
        }
    }    
}

struct TextEView: View {
    @State private var fullText: String = "This is some editable text..."
    var body: some View {        
         TextEditor(text: $fullText)
    }
}

By default the first list added to a view seems to be set to sidebar. Even if you don't specifically call .listStyle(SidebarListStyle()).

Is there any way that the list you set on the view (even if it's the first view) is not set to a sidebar? There is no indication on the Apple's documentation, and anything I have tried to style the list is not working.

So instead of the list looking like this:

enter image description here

It should look like:

enter image description here

Edit:

Yes, code. Any simple code will do.

struct ContentView: View {
    var body: some View {
        List {
                NavigationLink(
                    destination: TextEView(),
                ) {
                    Text("One")
                }
        }
    }    
}

struct TextEView: View {
    @State private var fullText: String = "This is some editable text..."
    var body: some View {        
         TextEditor(text: $fullText)
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七颜 2025-02-16 18:20:03

对于您的情况尝试

    List {
            NavigationLink(
                destination: TextEView(),
            ) {
                Text("One")
            }
    }
    .listStyle(.plain) // << here !!

For your case try

    List {
            NavigationLink(
                destination: TextEView(),
            ) {
                Text("One")
            }
    }
    .listStyle(.plain) // << here !!
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文