How can I change the background color of a list item while it is selected inside of a NavigationLink
?
It is always highlighted in blue (see the attached screen). I tried to change the listRowBackgroundColor
view modifier, but it didn't work.
NavigationView {
List (templateModel.model.items) { item in
NavigationLink(destination: DetailView(selectedCategory: item.name, dismiss: dismiss)
.environmentObject(OrientationInfo())) {
Text("Test")
.listRowBackground(Color.gray)
}
.background(Color.black)
.buttonStyle(PlainButtonStyle())
.listRowBackground(Color.gray)
}
.background(Color.black)
.listStyle(InsetListStyle())
}
Just use .accentColor
, as below
List (templateModel.model.items) { item in
// ... other content here
}
.accentColor(.gray) // << here !!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With