Search code examples
objective-cnstextfieldnsdatepicker

NSDatePicker vs. NSTextField border/bezel


I'm trying to make a textual NSDatePicker object look exactly like a NSTextField. If I take the standard objects it looks like this:

Standard

The only way I seem to find is making both objects bordered which looks like this:

Bordered

Does anyone know how to make the NSDatePicker border look like the textfield in the first image?


Solution

  • How about this?
    And don't use NSTextFieldAndStepperDatePickerStyle, please...

    - (void)viewDidLoad {
        [super viewDidLoad];
    
        // _picker is NSDatePicker as outlet
        _picker.bordered = NO;
        _picker.wantsLayer = YES;
        _picker.layer.borderWidth = 1;
        _picker.layer.borderColor = [NSColor lightGrayColor].CGColor;
    }