Edw*_* S. 2 macos swift swiftui
我正在尝试使用 SwiftUI/Swift 5.2 在 macOS 上创建一个白色的 ProgressView 微调器:
ProgressView()
.progressViewStyle(CircularProgressViewStyle(tint: Color.white))
.accentColor(Color.white)
Run Code Online (Sandbox Code Playgroud)
然而,这似乎并没有改变颜色。我用谷歌搜索过,但不知道如何改变颜色。
任何帮助,将不胜感激。
你需要给它一个value. 没有它,它只会显示一个无限微调器,对它progressViewStyle没有任何影响。
struct ContentView: View {
@State private var percentage = 0.6
var body: some View {
ProgressView(value: percentage) /// here!
.progressViewStyle(CircularProgressViewStyle(tint: Color.red))
}
}
Run Code Online (Sandbox Code Playgroud)
如果您希望无限期微调器为白色,请尝试 a colorSchemeof .dark。这迫使它呈现暗模式外观。
ProgressView()
.colorScheme(.dark)
.background(Color.black) /// for testing purposes
Run Code Online (Sandbox Code Playgroud)
结果:
| 归档时间: |
|
| 查看次数: |
514 次 |
| 最近记录: |