Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI disable list border iOS 14 [duplicate]

I found the list in SwiftUI iOS 14 will have something like border if the view contained navigationView. Is there any solution to disable the border? Coz the border break the design of my application.

Here is the code that contained no NavigationView inside the code.

struct ContentView: View {
    @State var isPresent = false
    
    var body: some View {
        let first = Restaurant(name: "Joe's Original")
        let second = Restaurant(name: "The Real Joe's Original")
        let third = Restaurant(name: "Original Joe's")
        let restaurants = [first, second, third]
            VStack{
                List(restaurants) { restaurant in
                    Text(restaurant.name)
                }
            }
        }
    }
}

enter image description here

Here is the code that contained NavigationView

struct ContentView: View {
    @State var isPresent = false
    
    var body: some View {
        let first = Restaurant(name: "Joe's Original")
        let second = Restaurant(name: "The Real Joe's Original")
        let third = Restaurant(name: "Original Joe's")
        let restaurants = [first, second, third]
        NavigationView{
            VStack{
                List(restaurants) { restaurant in
                    Text(restaurant.name)
                }

            }
        }
    }
}

enter image description here

The design that I want is the first photo. I have no idea how to disable the border that added into the list iOS14. Any suggestion?

like image 238
SAS231 Avatar asked Sep 03 '25 07:09

SAS231


1 Answers

Try to use plain list style explicitly (I assume now they used inset list style by default)

    NavigationView{
        VStack{
            List(restaurants) { restaurant in
                Text(restaurant.name)
            }
            .listStyle(PlainListStyle())     // << here !!
        }
    }
like image 98
Asperi Avatar answered Sep 05 '25 00:09

Asperi