【发布时间】:2012-04-18 02:27:21
【问题描述】:
我想知道状态栏图标在屏幕上的位置
-(void)awakeFromNib{
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];
NSBundle *bundle = [NSBundle mainBundle];
statusImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"r" ofType:@"png"]];
statusHighlightImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"rh" ofType:@"png"]];
[statusItem setImage:statusImage];
[statusItem setAlternateImage:statusHighlightImage];
[statusItem setTitle:@"APP"];
[statusItem setToolTip:@"You do not need this..."];
[statusItem setHighlightMode:YES];
NSRect rect = [[[statusItem view] window ] frame];
NSLog(@"%f",rect.origin.y);
}
这样做并没有得到
NSRect rect = [[[statusItem view] window ] frame];
NSLog(@"%f",rect.origin.y);
【问题讨论】:
标签: objective-c xcode macos cocoa