Changing default highlight color of NSDatePicker

399 Views Asked by At

I am subclassing NSDatePicker to implement calendar widget. I am able to change text color by setting textColor property of NSDatePicker but when I click on any field of NSDatePicker like Month/Year/Day the default color is somewhat blue.

I want to change highlight color to some custom color but I am not able to do that. I tried overriding highlightColorWithFrame:inView: and highlight:withFrame:inView: but no effect. This is how it looks at present

enter image description here

1

There are 1 best solutions below

8
Marc T. On

I would not recommend to change the selection color of a control since maxOS Mojave will allow the user to customise the Accent color in system preferences.

If ever you are still looking for customisation you must customise the drawing of the NSDatePickerCell and not of the control itself. I would try to overwrite

draw(withFrame cellFrame: NSRect, in controlView: NSView)

but for NSDatePickerCell it may be some more difficult since there are multiple datePicker elements.