您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页MAC:NSStatusBar

MAC:NSStatusBar

来源:二三娱乐
目录  
  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)

NSStatusBar1.png
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);
    
}

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务