this answer中所述,可以使用内容过滤器(在这种特定情况下,是“色调调整”内容过滤器)更改进度条的颜色。
似乎您只能在Xcode的接口生成器中实现这一点;但是,我希望以编程方式启用/禁用内容筛选器。例如,我想启用色调调整内容过滤器,使进度条变为绿色,稍后在函数中禁用它,使其变回蓝色。这可能吗?

最佳答案

在一个错误的开始之后,答案似乎很简单:

// Need to set this in code. The settings in IB don't carry over when
// I change the contentFilters
progressIndicator.minValue = 0
progressIndicator.maxValue = 100
progressIndicator.doubleValue = 50

let hueAdjust = CIFilter(name: "CIHueAdjust", withInputParameters: ["inputAngle": NSNumber(value: 1.7)])!
progressIndicator.contentFilters = [hueAdjust]

10-08 08:04
查看更多