You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS16 SwiftUI中如何修改ProgressView的进度条颜色(非背景)

解决SwiftUI ProgressView进度条颜色修改问题

由于LinearProgressViewStyle的tint参数已被废弃,你无需再通过样式类传递颜色,直接给ProgressView添加tint修饰符即可设置进度条颜色:

ProgressView()
    .tint(.red)
    .progressViewStyle(LinearProgressViewStyle())
    .background(.yellow)

如果使用的是带进度值的ProgressView,写法同样适用:

ProgressView(value: 0.7)
    .tint(.red)
    .progressViewStyle(LinearProgressViewStyle())
    .background(.yellow)

若需要更复杂的样式定制,也可以自定义ProgressViewStyle实现,但针对单纯修改进度条颜色的需求,tint修饰符是最直接高效的方案。

内容的提问来源于stack exchange,提问作者Pro Girl

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 08:49:55