Joz*_*zan 5 cocoa objective-c title statusbar
//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];
如何将"myTitle"fe的颜色改为蓝色?像PeerGuardian这样的应用程序在其列表被禁用时将其状态栏项目标题更改为红色,所以我想这在某种程度上是可能的.
谢谢!
使用NSStatusItem的-setAttributedTitle方法,并给它一个NSAttributedString合适的颜色:
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];
| 归档时间: | 
 | 
| 查看次数: | 1977 次 | 
| 最近记录: |