更改菜单栏应用程序

更改菜单栏应用程序

可能存在一种简单的方法来更改菜单栏应用程序标题的字体大小,从而使@“ title”的显示小于(或大于)默认值

statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];

[statusItem setHighlightMode:YES];
[statusItem setTitle:@"title"];
[statusItem setMenu:statusMenu];

最佳答案

响应Eugene,为实现图标和标题显示,我打算使用下面发布的方法

statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];

NSFont *font = [NSFont fontWithName:@"LucidaGrande" size:12.0];
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"title" attributes:attrsDictionary];

NSBundle *bundle = [NSBundle mainBundle];

statusImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"icon" ofType:@"png"]];
statusHighlightImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"icon-alt" ofType:@"png"]];

[statusItem setImage:statusImage];
[statusItem setAlternateImage:statusHighlightImage];
[statusItem setHighlightMode:YES];
[statusItem setAttributedTitle:attrString];
[statusItem setMenu:statusMenu];


我打算发布一个指向教程的链接,该链接很好地解释了某些代码的大部分原因
http://www.sonsothunder.com/devres/revolution/tutorials/StatusMenu.html

关于macos - 更改菜单栏应用程序的字体大小,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17266717/

10-10 20:33