2

How can I change background color of scroller at NSTableView? For example I've made black background color of my TableView and got white scroller, I want ClearColor or Black color of Scroller's background. How can I make it?

example

Vasily
  • 3,740
  • 3
  • 27
  • 61

1 Answers1

2

You'll need to subclass NSScroller and override its -(void)drawRect: method

- (void)drawRect:(NSRect)dirtyRect
{
    // the only line is required
    [self drawKnob];
}
Daniyar
  • 2,975
  • 2
  • 26
  • 39
  • That answer have one issue. If knob is not needed to be displayed (e.g. tableView has only 1 row) your function displays knob. It's any way to check if knob is needed to be displayed and than call `drawKnob`? – Vasily Oct 12 '15 at 10:35
  • Couldn't find any easy solution. You should add property isVisible (`if (self.isVisible) [drawKnob];`) and set its value somewhere in your `NSTableView` class according to contents height. – Daniyar Oct 12 '15 at 12:39
  • It's really so strange that Apple uses transparent knobs in native applications but there is no simple solution in XCode – Vasily Oct 12 '15 at 13:55
  • Knobs started being opaque since El Capitan if I'm not mistaken. – Daniyar Oct 12 '15 at 14:12