Since iOS 14 i have a strange behavior where i have a padding around a list in a NavigationView as soon as i add navigationBarItems...
My code :
import SwiftUI
struct TestList: View {
var body: some View {
NavigationView{
List {
Text("hello world")
Text("hello world")
Text("hello world")
}
.navigationBarTitle(Text("Test List"), displayMode:.inline)
.navigationBarItems(leading:
Image(systemName: "bell")
)
}
}
}
struct TestList_Previews: PreviewProvider {
static var previews: some View {
TestList()
}
}
How can i fix this?
Thanks
Ok i got it...
I need to add a ListStyle to the list :
https://developer.apple.com/documentation/swiftui/liststyle
import SwiftUI
struct TestList: View {
var body: some View {
NavigationView{
List {
Text("hello world")
Text("hello world")
Text("hello world")
}
.listStyle(PlainListStyle())
.navigationBarTitle(Text("Test List"), displayMode:.inline)
.navigationBarItems(leading:
Image(systemName: "bell")
)
}
}
}
struct TestList_Previews: PreviewProvider {
static var previews: some View {
TestList()
}
}