Changing the color of NSProgressIndicator?

前端 未结 5 919
终归单人心
终归单人心 2020-12-17 21:12

What is the best way to change the color of NSProgressIndicator, is there an easier way than just to subclass it and then draw the whole component by myself?

Basical

相关标签:
5条回答
  • 2020-12-17 21:55

    For Swift the method name is controlTint.

    progressIndicator = NSProgressIndicator(frame: .......
    progressIndicator.controlTint = .blueControlTint
    
    0 讨论(0)
  • 2020-12-17 22:00

    Use "CIFalseColor" filter to get white color and more.

    let colorFilter = CIFilter(name: "CIFalseColor")!
    colorFilter.setDefaults()
    colorFilter.setValue(color1, forKey: "inputColor0")
    colorFilter.setValue(color2, forKey: "inputColor1")
    proggressBar?.contentFilters = [colorFilter]
    
    0 讨论(0)
  • 2020-12-17 22:01

    you can use proggressBar.appearance = NSAppearance(named: .vibrantLight) // this is light or vibrantDark for "black" indictor

    0 讨论(0)
  • 2020-12-17 22:02

    You can use Quartz filters (e.g. hue adjust) for this directly in Interface Builder. This works better than expected.

    NSProgressIndicator

    It's in the Effects Inspector. Under "Content Filters" you can add "Hue Adjust"

    0 讨论(0)
  • 2020-12-17 22:12

    To change color of NSProgressIndicator use setControlTint: method. If you want to set custom color you have to draw such control manually. However, you should use the system color to keep this kind of control consistent across the system.

    0 讨论(0)
提交回复
热议问题