NSScroller background in dark mode

Hi ,

I am facing an issue regarding NSScroller. In Mojave dark mode my scroller is translucent. When I push a NSViewController it makes translucent on scroller area. If I select reduce transparency from settings --> Accessibility then it looks good. I have subclass NSScroller and tried to change background color. it changes background color but again these is transparency. Any idea how I can fix this issue.

Here is my code

class CustomScroller: NSScroller {


override func draw(_ dirtyRect: NSRect) {

_bkgrColour.setFill()

dirtyRect.fill()



}


}







Thanks.

Replies

It seems you have to use layers:


https://developer.apple.com/documentation/appkit/supporting_dark_mode_in_your_interface


proposed example (Swift)

override func updateLayer() {
  self.layer?.backgroundColor = NSColor.textBackgroundColor.cgColor

  // Other updates.
}