Nie*_*els 5 swift swiftui swiftui-list swiftui-navigationlink
在 a 中选择列表项时,如何更改它的背景颜色NavigationLink
?
它始终以蓝色突出显示(请参阅附加屏幕)。我试图更改listRowBackgroundColor
视图修改器,但没有用。
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())
}
Run Code Online (Sandbox Code Playgroud)
只需使用.accentColor
,如下所示
List (templateModel.model.items) { item in
// ... other content here
}
.accentColor(.gray) // << here !!
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
757 次 |
最近记录: |