//Create the NSStatusBar and set its length
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
[statusItem setHighlightMode:YES];
[statusItem setTitle:@"myTitle"];
[statusItem setToolTip:@"myToolTip"];
[statusItem setMenu:statusMenu];
[statusItem setEnabled:YES];
How to change color of "myTitle" to blue?
Some applications like PeerGuardian change their status bar item titles to red when their lists are disabled, so I guess this is somehow possible.
Use NSStatusItem
's -setAttributedTitle
method, and give it an NSAttributedString
of the appropriate color:
NSDictionary *titleAttributes = [NSDictionary dictionaryWithObject:[NSColor blueColor] forKey:NSForegroundColorAttributeName];
NSAttributedString* blueTitle = [[NSAttributedString alloc] initWithString:@"myTitle" attributes:titleAttributes];
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
[statusItem setAttributedTitle:blueTitle];
[blueTitle release];
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