状态栏应用

  1. 新建一个Application 为 App 的project

  2. AppDelegate中添加代码 显示状态栏按钮

     statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength) 
     statusBarItem.menu = menu
     statusBarItem.button?.image = NSImage(named: "settings")
     statusBarItem.button?.target = self
     statusBarItem.isVisible = true
    
  3. info.plist Application is agent (UIElement) = YES 不显示在Dock

  4. Main.storyboard 中的窗口删除 没有程序主窗口了

你可能感兴趣的:(状态栏应用)