I am using a ListView in Mac OS. I am trying to change that background color of that ListView. However, it is not that easy as expected.
I tried using .background(Color(.red))
attribute on the ListView. That didn't change anything.
I could only find .listRowBackground(Color(.red))
which had an influence on the table rows. However, the other background wasn't effected.
I prepared a little demo to demonstrate:
In my view body:
VStack
{
List()
{
Text("Test")
.listRowBackground(Color.green)
Text("Test")
.listRowBackground(Color.green)
Text("Test")
.listRowBackground(Color.green)
}.background(Color(.red))
}.background(Color(.red))
That is the result I get:
The main background does not change. I read about a solution changing the UITableView.appearance
but that is not possible for me in SwiftUI for Mac OS.
Thanks in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…