I believe you are using swiftUI.
I am having the same issue with my project. When you wrap a List in the NavigationView, a weird padding appears, and the background colours of the List and the NavigationView are slightly different.
I go through a lot of testing and found that if you just wrap the List in NavigationView, it looks absolutely fine, but if you add something like navigationItems. The weird padding appears again.
This is perfectly fine, no weird padding.
struct DemoView: some View {
var body: some View {
NavigationView {
List {
Text("some text")
Text("some text")
Text("some text")
Text("some text")
}
}
}
}
This gets some weird padding, by just adding a navigation bar item.
struct DemoView: some View {
var body: some View {
NavigationView {
List {
Text("some text")
Text("some text")
Text("some text")
Text("some text")
}
.navigationBarItems(leading: Text("an item"))
}
}
}
And you still get a padding, even if you do not do anything affecting the appearance, like add a popover.
struct DemoView: some View {
@State var showAddItemMenu = false
var body: some View {
NavigationView {
List {
Text("some text")
Text("some text")
Text("some text")
Text("some text")
}
.popover(isPresented: $showAddItemMenu) { addItemMenu }
}
}
}
I have no idea why this would happen, it kinda stop me from building my app since the padding is so ugly.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: