I am using a "spinner" NSProgressIndicator in my cocoa app:
I would like to display it in a different color so that it will show up well on a dark background:
How would I go about doing this? My last resort would be to write my own custom NSView subclass that renders a custom animation, but I'm not even sure where to start on that front. Any help is appreciated.
This is what I've done:
#import <QuartzCore/QuartzCore.h>
...
CIFilter *lighten = [CIFilter filterWithName:@"CIColorControls"];
[lighten setDefaults];
[lighten setValue:@1 forKey:@"inputBrightness"];
[self.indicator setContentFilters:[NSArray arrayWithObjects:lighten, nil]];
I actually have implemented clones of the spinning NSProgressIndicator that might suit your needs. They can be drawn at any size and in any color. One is a subclass of NSView, which can be used on OS X 10.4, and the other is a subclass of CALayer, which can be used in a CoreAnimation-based project. The code is on github (both the NSView-based version and the CoreAnimation-based version), and there is a post with some screenshots on my blog.
Not sure if this would work correctly with NSProgressIndicator, but you might try using a Core Image filter to invert the display of the progress indicator view. You would have to make the view layer backed, and then add a CIFilter
to its layer's filters. You may be able to do this all in the effects inspector in Interface Builder, otherwise you could also just do it in code.
While I'm sure that Kelan's code worked a while ago, it's difficult to update. I ended up going with ITProgressIndicator, and it took about 2 minutes to get working using Xcode 6 (Beta 1) and Yosemite (Beta 2).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With