In Table view, how do I customize the background color of a selected row?

112 views Asked by At

I'm making a macOS app using SwiftUI. I have a Table view. I have selection enabled but I can't find any way to customize the selection color - it's always blue.

My table looks something like this:

Table(of: MyObj.self, selection: $selectedID, sortOrder: $sortOrder) {
        TableColumn("Column Name") { obj in
            // do some custom view
        }
        // ...
    } rows: {
        Foreach (model.items) { obj in
            TableRow(obj)
        }
    }
}

The selection color is always the royal blue color. This doesn't match with colors in my app, and colors of text and icons in the row don't look good against this blue color.

1

There are 1 answers

5
lorem ipsum On

You can change the "AccentColor" in "Assets" to override the default Apple systemBlue accent color everywhere in your app.