Display image in a cocoa status app

瘦欲@ 提交于 2019-12-05 19:02:44

问题


Hi I developed a cocoa status app. when I put a long title for example , it can't be shown and if i put an image as icon too it can't be shown , but if i put a small title it works correctly. How can I fix this problem and make the image shown?

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

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

回答1:


Basically

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

But your image has to be at a correct size (less than 20*20)



来源:https://stackoverflow.com/questions/11411231/display-image-in-a-cocoa-status-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!