How to get the on-screen location of an NSStatusItem

前端 未结 7 694
暖寄归人
暖寄归人 2020-12-05 01:27

I have a question about the NSStatusItem for cocoa in mac osx. If you look at the mac app called snippets (see the movie at http://snippetsapp.com/). you will s

相关标签:
7条回答
  • 2020-12-05 02:04

    Maybe another solution which works for me (swift 4.1) :

       let yourStatusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
    
       let frameOrigin = yourStatusItem.button?.window?.frame.origin
       let yourPoint = CGPoint(x: (frameOrigin?.x)!, y: (frameOrigin?.y)! - 22)
    
    
       yourWindow?.setFrameOrigin(yourPoint)
    
    0 讨论(0)
提交回复
热议问题