1. Info.plist 添加 LSUIElement,設(shè)置為YES
LSUIElement(String)蟹腾。 如果此鍵設(shè)置為“1”,則啟動服務(wù)將應(yīng)用程序作為代理應(yīng)用程序運行。 代理應(yīng)用程序不會出現(xiàn)在Dock或強(qiáng)制退出窗口中。 雖然它們通常作為后臺應(yīng)用程序運行鲫趁,但如果需要,它們可以到前臺呈現(xiàn)用戶界面利虫。
2. 自定義隱藏/顯示
- Info.plist 添加 LSUIElement挨厚,設(shè)置為NO
- 在啟動時調(diào)用下面代碼。
if (show) {
ProcessSerialNumber psn = {0, kCurrentProcess};
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
}else{
// do nothing
}
參考文檔:
https://stackoverflow.com/questions/620841/how-to-hide-the-dock-icon