因此,我对某个项目的图像有疑问,就像您在这张图片中看到的NSStatusBar
那样,该图像似乎正在远离其余的菜单项。但是,当菜单栏处于非活动状态时(如我在我的另一台显示器上或不在应用程序中),问题不会发生,正如您在这张图片中看到的那样。我很确定我的代码是正确的。
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"]];
}
我查看了这个问题:在可可状态应用程序中显示图像但问题仍然存在,所以我不确定还能做什么,感谢您的帮助!PS:我认为的问题是NSVariableStatusItemLength
,我试过NSSquareStatusItemLength
但没有运气,也尝试过自己设置,但同样的问题,但几乎没有改善。