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.
You need to give it a value
. Without that, it just displays an infinite spinner, which progressViewStyle
has no effect on.
struct ContentView: View {
@State private var percentage = 0.6
var body: some View {
ProgressView(value: percentage) /// here!
.progressViewStyle(CircularProgressViewStyle(tint: Color.red))
}
}
If you want the indefinite spinner to be white, try a colorScheme
of .dark
. This forces it to take on its dark mode appearance.
ProgressView()
.colorScheme(.dark)
.background(Color.black) /// for testing purposes
Result:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.