I set the placeholder text of my NSTextField in Interface Builder, but the placeholder text doesn\'t show until I click inside the text field to edit it.
Have you bound the NSTextField data in Interface Builder? If so, you have to set the "Multiple Values Placeholder", "No Selection Placeholder" and "Null Placeholder" in the bindings tab in your Utilities inspector. While youre at it, you could set the "No Applicable Placeholder" as well.
Have you tried setting the placeholder through code? for example something like this:
[[textField cell] setPlaceholderString:@"hello"];
This is how I solve this problem:
NSTextFieldCell
;- (void)drawWithFrame:(NSRect)cellFrame
, - (void)drawInteriorWithFrame:
(if need) method(s) of NSCell
and put all drawing code you need to those methods. Don't forget to call super
implementation;Class
field of NSTextFieldCell
in Interface Builder
to your subclass; border
in .xib
file to (I don't know name of this border);Draw Background
;