简体   繁体   中英

SwiftUI SidebarListStyle inside of NavigationView's Style

i'm new with SwiftUI. My goal is to make List which listStyle is SidebarListStyle just exactly like this [first][1]

and here's my code

            List{
            MyProfile()
            Section(header:
                        Text("친구 102")
                        .font(.footnote)
                        .foregroundColor(.secondary)
            ){
                FriendsList()
            } // Section
        } // List
        .listStyle(SidebarListStyle())

But if i put this code inside NavigationView , listStyle changes without my intention like this [second][2]

and code

        NavigationView{
        List{
            MyProfile()
            Section(header:
                        Text("친구 102")
                        .font(.footnote)
                        .foregroundColor(.secondary)
            ){
                FriendsList()
            } // Section
        } // List
        .listStyle(SidebarListStyle())
    }

any help? [1]: https://i.stack.imgur.com/awX3H.png [2]: https://i.stack.imgur.com/vMBZn.png

You can use StackNavigationViewStyle

NavigationView{
        List{
            MyProfile()
            Section(header:
                        Text("친구 102")
                        .font(.footnote)
                        .foregroundColor(.secondary)
            ){
                FriendsList()
            } // Section
        } // List
        .listStyle(SidebarListStyle())
    }
  .navigationViewStyle(StackNavigationViewStyle())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM