Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change ProgressView accentColor in SwiftUI?

Tags:

ios

swift

swiftui

This doesn't apply

ProgressView("\(spinnerLabel)")
    .accentColor(.white)

This changes the label

.foregroundColor(.white)

enter image description here

like image 332
Marcus Ziadé Avatar asked Oct 09 '20 10:10

Marcus Ziadé


People also ask

How do I customize ProgressView SwiftUI?

To make a custom ProgressView style, you need to create a struct that has a makeBody() method accepting the current configuration of the view.

How do I turn off ProgressView in SwiftUI?

In the example How to show progress on a task using ProgressView is using the DefaultProgressViewStyle or LinearProgressViewStyle . If you want the Progress indicator to stop you will need to dismiss the ProgressView .


2 Answers

Try the following:

For iOS15+

.tint(.white)

For iOS13+

.progressViewStyle(CircularProgressViewStyle(tint: Color.white))
like image 141
Theo Lampert Avatar answered Oct 01 '22 01:10

Theo Lampert


The selected answer contains a deprecated method, init(tint:).

This is the new way to change the tint color:

ProgressView()
    .tint(.white)
like image 44
Dylan Hand Avatar answered Oct 01 '22 03:10

Dylan Hand