美文网首页Mac开发云集
macOS开发 - 隐藏底部Dock图标

macOS开发 - 隐藏底部Dock图标

作者: whbalzac | 来源:发表于2019-01-12 16:02 被阅读0次

1. Info.plist 添加 LSUIElement,设置为YES

LSUIElement(String)。 如果此键设置为“1”,则启动服务将应用程序作为代理应用程序运行。 代理应用程序不会出现在Dock或强制退出窗口中。 虽然它们通常作为后台应用程序运行,但如果需要,它们可以到前台呈现用户界面。

2. 自定义隐藏/显示

  • Info.plist 添加 LSUIElement,设置为NO
  • 在启动时调用下面代码。
    if (show) {
        ProcessSerialNumber psn = {0, kCurrentProcess};
        TransformProcessType(&psn, kProcessTransformToUIElementApplication);
    }else{
        // do nothing
    }

参考文档:

https://stackoverflow.com/questions/620841/how-to-hide-the-dock-icon

相关文章

网友评论

    本文标题:macOS开发 - 隐藏底部Dock图标

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