Hi team,
I develop app for MacOS. To set the color of NSProgressIndicator I used contentFilters. It works fine on Catalina and Mojave. But on Big Sur, non of the contentFilters property work.
Below code work fine with Catalina and Mojave, but does not work on Big Sur. The progress indicator is invisible.
extension NSProgressIndicator {
func set(tintColor: NSColor) {
guard let adjustedTintColor = tintColor.usingColorSpace(.deviceRGB) else {
contentFilters = []
DDLogVerbose("guard is returned")
return
}
let tintColorRedComponent = adjustedTintColor.redComponent
let tintColorGreenComponent = adjustedTintColor.greenComponent
let tintColorBlueComponent = adjustedTintColor.blueComponent
let tintColorMinComponentsVector = CIVector(x: tintColorRedComponent, y: tintColorGreenComponent, z: tintColorBlueComponent, w: 0.0)
let tintColorMaxComponentsVector = CIVector(x: tintColorRedComponent, y: tintColorGreenComponent, z: tintColorBlueComponent, w: 1.0)
let colorClampFilter = CIFilter(name: "CIColorClamp")!
colorClampFilter.setDefaults()
colorClampFilter.setValue(tintColorMinComponentsVector, forKey: "inputMinComponents")
colorClampFilter.setValue(tintColorMaxComponentsVector, forKey: "inputMaxComponents")
DDLogVerbose("color is returned")
contentFilters = [colorClampFilter]
}
}