NSStatusItem change image for dark tint

后端 未结 6 1570
面向向阳花
面向向阳花 2020-12-12 16:40

With OSX 10.10 beta 3, Apple released their dark tint option. Unfortunately, it also means that pretty much all status bar icons (with the exception of Apple\'s and Path Fin

6条回答
  •  轮回少年
    2020-12-12 17:13

    Newest swift code set image template method is here:

    // Insert code here to initialize your application
    if let button = statusItem.button {
        button.image = NSImage(named: "StatusIcon")
        button.image?.isTemplate = true  // Just add this line
        button.action = #selector(togglePopover(_:))
    }
    

    Then it will change the image when dark mode.

提交回复
热议问题