I've encountered this issue recently as well, but mine was related to Dark mode / Light mode in macOS 10.14. It seems to happen when using an NSProgressIndicator inside an NSPopover, as others have mentioned, but also inside a Safari App Extension popover (I think this is because the Safari popover is also an NSPopover that you can't access directly). As horimislime mentioned, messing around with the appearance seems to fix things.
I've created an NSProgressIndicator subclass that, only when the app is running in macOS 10.14 or greater, automatically sets its own appearance to the one the system has, even if this changes while the app is running. The Progress Indicator works for me in previous OS versions, so I left it unchanged if the system is less than 10.14.
Here is the code:
import Cocoa
class TransparentProgressIndicator: NSProgressIndicator {
override func awakeFromNib() {
super.awakeFromNib()
if #available(OSX 10.14, *) {
// register an observer to detect when the system appearance changes
UserDefaults.standard.addObserver(self, forKeyPath: "AppleInterfaceStyle", options: .new, context: nil)
// set the starting appearance to the one the system has
let light = NSAppearance(named: .aqua)
let dark = NSAppearance(named: .darkAqua)
self.appearance = UserDefaults.standard.string(forKey: "AppleInterfaceStyle") == "Dark" ? dark : light
}
}
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if #available(OSX 10.14, *) {
if keyPath == "AppleInterfaceStyle" {
// set the current appearance to the one the system has
let val: String? = change?[NSKeyValueChangeKey.newKey] as? String
if (val == "Dark") {
self.appearance = NSAppearance(named: .darkAqua)
}
else {
self.appearance = NSAppearance(named: .aqua)
}
}
}
}
deinit {
if #available(OSX 10.14, *) {
UserDefaults.standard.removeObserver(self, forKeyPath: "AppleInterfaceStyle")
}
}
}
This way, the progress indicator stays transparent with no weird tinted background and still changes its color scheme according to the system appearance.
In order to use this, you need to add the name of this subclass as the "Custom Class" property in interface builder:
Now, in order to have a custom background color as requested in the question, you can just have a containing NSBox and add a color to that: