Change SwiftUI ProgressView Color - macOS not iOS

Viewed 2937

I am attempting to create a white ProgressView spinner on macOS using SwiftUI / Swift 5.2 using:

ProgressView()
    .progressViewStyle(CircularProgressViewStyle(tint: Color.white))
    .accentColor(Color.white)

However this does not seem to change the color. I have googled and searched but cannot figure how to change the color.

Any help would be appreciated.

1 Answers

As of iOS 15 it seems like your code works:

struct ContentView: View {
    var body: some View {
        ProgressView()
            .progressViewStyle(CircularProgressViewStyle(tint: Color.white))
            .padding()
            .background(.black)
    }
}

Note that .tint(Color.white) also works, but the deprecated .accentColor(Color.white) does not.

White spinner on black background

I'm pretty sure back in iOS 14 progressViewStyle had no effect on indeterminate spinners, so for a more backwards-compatible version try something like this:

struct ContentView: View {
    var body: some View {
        ProgressView()
            .colorInvert() /// make the spinner a semi-opaque white
            .brightness(1) /// ramp up the brightness
            .padding()
            .background(.black)
    }
}
Related