Add/remove application icon from dock at runtime?

前端 未结 1 1139
感情败类
感情败类 2020-12-31 23:48

Is there a public Apple API which allows you to remove an application\'s dock icon at runtime? I have tried substituting an empty view with zero size via NSApplication\'s d

相关标签:
1条回答
  • 2021-01-01 00:38

    It's a one way street: You can set your app to NSUIElement to hide the dock icon, then call [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; to show it in the dock, but once it's there you can't remove it. So you could make the dock icon user-configurable, but you'd have to relaunch the app to hide the icon.


    EDIT

    You can call setActivationPolicy:NSApplicationActivationPolicyProhibited to hide dock-icon again – user1592530 Sep 18 '12 at 14:21

    The comment is right. Works two ways nowadays – Daij-Djan Dec 24 '12 at 11:46


    0 讨论(0)
提交回复
热议问题