在可可状态应用程序中显示图像 [英] Display image in a cocoa status app

查看:141
本文介绍了在可可状态应用程序中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我开发了一个可可状态应用程序。当我把一个长的标题为例,它不能显示,如果我把一个图像作为图标,它不能显示,但如果我放一个小标题它工作正常。
如何解决这个问题并显示图片?

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];


推荐答案

基本上

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

但您的图片必须是正确的大小(小于20 * 20)

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

这篇关于在可可状态应用程序中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆