【发布时间】:2015-11-14 00:51:03
【问题描述】:
所以我对NSStatusBar 项目的图像有问题,看起来图像正在推离其余菜单项as you can see in this picture. 但是当菜单栏处于非活动状态时(如我在我的其他显示器上或不在应用程序中)问题不会发生as you can see in this picture。不过我很确定我的代码是正确的。
statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[statusItem setHighlightMode:YES];
[statusItem setAction:@selector(openWindow)];
[statusItem setTarget:self];
if ([[[NSAppearance currentAppearance] name] containsString:NSAppearanceNameVibrantDark]) {
[statusItem setImage:[NSImage imageNamed:@"whiteMenu.png"]];
} else {
[statusItem setImage:[NSImage imageNamed:@"blackMenu.png"]];
}
我查看了这个问题:Display image in a cocoa status app 但问题仍然存在,所以我不知道还能做什么,感谢您的帮助! PS:我认为是NSVariableStatusItemLength的问题,我试过NSSquareStatusItemLength但没有运气,也尝试自己设置,但同样的问题,但几乎没有改善。
【问题讨论】:
标签: objective-c macos cocoa nsstatusitem nsstatusbar