目录
1.1 简单实现
1.2 隐藏下方Icon
1.3 下方Icon点击事件
1.4 删除Main.storyboard
1.1 简单实现
NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
self.statusItem = [statusBar statusItemWithLength:NSSquareStatusItemLength];
NSImage *image = [NSImage imageNamed:@"statusBarIcon"];
image.template = YES;
self.statusItem.button.image = image;
NSStatusBarButton *button = self.statusItem.button;
button.target = self;
button.action = @selector(handleButtonClick:);
- (void)handleButtonClick:(id)sender
{
}
1.2 隐藏下方Icon
设置YES为隐藏
Application is agent (UIElement)
1.3 下方Icon点击事件
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender
hasVisibleWindows:(BOOL)flag{
self.homeViewController = [[DDHomeViewController alloc]
initWithWindowNibName:@"DDHomeViewController"];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
[self.homeViewController showWindow:nil];
return YES;
}
1.4 删除Main.storyboard
int main(int argc, const char * argv[]) {
NSApplication *app = [NSApplication sharedApplication];
id delegate = [[AppDelegate alloc] init];
app.delegate = delegate;
return NSApplicationMain(argc, argv);
}