在 NavigationLink
中选择列表项时,如何更改它的背景颜色?
它始终以蓝色突出显示(请参阅附加屏幕)。我试图改变 listRowBackgroundColor
View 修饰符,但它不起作用。
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())
}
最佳答案
List (templateModel.model.items) { item in
// ... other content here
}
.accentColor(.gray) // << here !!
关于swift - iOS 14、Swift UI 2 更改 NavigationLink 内所选列表项的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63977370/