When the NSTextField (Label) is bound to a controller selection with bindings, and I have specified placeholder values for the Multiple Values Marker, No Selection Marker, etc it draws the text with a gray color that does not show up well on a dark background.
Is there a way to change the text color it uses to display the placeholder text?
Use an attributed string specifying the color you want, like this:
NSDictionary *blueDict = [NSDictionary dictionaryWithObject: [NSColor blueColor]
forKey: NSForegroundColorAttributeName];
NSAttributedString *blueString = [[[NSAttributedString alloc] initWithString: @"test"
attributes: blueDict] autorelease];
Then you can either set the placeholder attributed string directly:
[[field cell] setPlaceholderAttributedString: blueString];
or do it through a binding, for example:
[field2 bind: @"value" toObject: [NSUserDefaults standardUserDefaults]
withKeyPath: @"foo"
options: [NSDictionary dictionaryWithObject: blueString forKey: NSNullPlaceholderBindingOption]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With