When I work with NavigationView, NavigationTitle, List, and search field, there is an annoy display error.
The search field and NavigationTitle are not align with the List.
If the next page has searchable List, pull the next page list down and show the search bar totally, alignment will return to normal. But if you go back to the first page and pull down the search bar again, the same error will appear.
Just create a new project with Core Data, and replace the NavigationView to this code, you can easily reproduce this bug.
Or, what did I do wrong?
NavigationView {
List {
ForEach(items) { item in
NavigationLink {
List{}.searchable(text: $text).navigationTitle("Test")
} label: {
Text(item.timestamp!, formatter: itemFormatter)
}
}
.onDelete(perform: deleteItems)
}.searchable(text: $text){}.navigationTitle("Title")
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
EditButton()
}
ToolbarItem {
Button(action: addItem) {
Label("Add Item", systemImage: "plus")
}
}
}
Text("Select an item")
}
}