gpt4 book ai didi

objective-c - 在 cocoa 状态应用程序中显示图像

转载 作者:太空狗 更新时间:2023-10-30 03:29:04 25 4
gpt4 key购买 nike

您好,我开发了一个 cocoa 状态应用程序。例如,当我放置一个长标题时,它无法显示,如果我也将图像作为图标放置,则无法显示,但如果我放置一个小标题,它就可以正常工作。我该如何解决这个问题并显示图像?

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

[statusItem setMenu:menu];
//[statusItem setTitle:@"Notif "];
[statusItem setImage:[NSImage imageNamed:@"image"]];
[statusItem setHighlightMode:YES];

最佳答案

基本上

NSStatusItem *statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
NSImage* icon = [NSImage alloc] initWith ...]
[statusItem setImage:icon];

但是你的图片必须是正确的尺寸(小于 20*20)

关于objective-c - 在 cocoa 状态应用程序中显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11411231/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com