美文网首页
macOS 添加Dock菜单

macOS 添加Dock菜单

作者: mapg | 来源:发表于2019-08-23 17:35 被阅读0次
    //NSApplicationDelegate 在dock上添加菜单
    - (NSMenu *)applicationDockMenu:(NSApplication *)sender {
        
        NSMenu *dockMenu = [[NSMenu alloc] initWithTitle:@"嗨新房"];
        [dockMenu setAutoenablesItems:NO];
        NSMenuItem *newItem0 = [[NSMenuItem alloc]
                                initWithTitle:@"修改头像"
                                action:@selector(takePhonto)
                                keyEquivalent:@""];
        NSMenuItem *newItem1 = [[NSMenuItem alloc]
                                initWithTitle:@"截屏"
                                action:@selector(grapScreen)
                                keyEquivalent:@""];
        
        [newItem0 setTarget: self];
        [newItem1 setTarget: self];
        [dockMenu addItem:newItem0];
        [dockMenu addItem:newItem1];
        return dockMenu;
    }
    
    -(void)takePhonto{
        //
    }
    
    //截屏
    -(void)grapScreen{
    //    if (App_Delegate.isLogin) {
    //        [Tools grabScreen];
    //    }else{
    //        [self showAlertWithMessageStr:@"提示" info:@"登陆后才能进行此操作"];
    //    }
    }
    
    image.png

    相关文章

      网友评论

          本文标题:macOS 添加Dock菜单

          本文链接:https://www.haomeiwen.com/subject/goitectx.html