I am using NSScroller in cocoa app. NSScroller is translucent in mojave dark mode but in looks fine in mojave light mode.
I have tried subclassing nsscroller and try to change background color. it changes background color but translucent effect is not disappearing.
class CustomScroller: NSScroller {
- (void)drawRect:(NSRect)dirtyRect {
NSColor.red.set()
__NSRectFill(dirtyRect)
self.drawKnob()
}
}
Maybe add this to your CustomScroller?
The venerable BGHUDAppKit provides an example of how to draw your own themes from scratch.
Most people hate it because its an unmaintainable mess. Despite this, I've kept my own version up to date for years :)
You'll need your own 'theme' implementation. For example
[[[self theme] scrollerStroke] set];needs to return an NSColor. A good rule of thumb for UI themes:the 10% rule The human eye can distinguish easily between brightness differences of 10%, so for example the scroll bar should be outlined with a color that is 10% brighter than the fill color. ( outline with 57.0/255.0, fill with 50.0/255.0 )
try to use grayscale colors as much as possible.
Here's my implementation, with notes included for various OS versions: