0

Code:

[NSApp setPresentationOptions: NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock];

It hides Dock and MenuBar OSX.

When I add key LSUIElement into my Info.plist file and rerun my code: Dock is hidden, but MenuBar doesn't hidden.

Why? How to hide MenuBar after adding LSUIElement?

Thomas Tempelmann
  • 11,045
  • 8
  • 74
  • 149
fhdnsYa
  • 443
  • 1
  • 6
  • 15

1 Answers1

2

Well, it should hide the main menu always and forever, but using LSUIElement in the plist is an older way of doing things than using both setActivationPolicy and setPresentationOptions so you might want to give [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory] a shot instead.

The LSUIElement way of doing things didn't support changes at runtime. You're mixing old and new. Deprecate LSUIElement and use setActivationPolicy on OSX 10.9+.

There is lots of discussion along these lines. This is a good answer. I wrote an answer about how to switch to accessory mode when the user "quits" the app here and that uses the runtime functionality which LSUIElement would break. So don't use it.

Community
  • 1
  • 1
stevesliva
  • 5,351
  • 1
  • 16
  • 39