我试图使用ProgressView /SWIFT5.2在macOS上创建一个白色的SwiftUI旋转器,使用:
ProgressView()
.progressViewStyle(CircularProgressViewStyle(tint: Color.white))
.accentColor(Color.white)然而,这似乎并没有改变颜色。我已经搜索和搜索,但不知道如何改变颜色。
任何帮助都将不胜感激。
发布于 2021-03-10 16:15:53
从iOS 15开始,您的代码似乎可以工作:
struct ContentView: View {
var body: some View {
ProgressView()
.progressViewStyle(CircularProgressViewStyle(tint: Color.white))
.padding()
.background(.black)
}
}请注意,.tint(Color.white)也能工作,但不推荐的.accentColor(Color.white)不起作用。

我非常肯定,在iOS 14中,progressViewStyle对不确定的纺丝器没有任何影响,所以要想获得更兼容的反向版本,请尝试如下所示:
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)
}
}https://stackoverflow.com/questions/66568382
复制相似问题