0
votes

I'm making a tiny menu bar app that shows the current iTunes song in the status bar. It works great, except for the fact that in dark mode, black areas of the album art show up the same color as the (transparent) menu bar background:

transparent-status-item-bg

Is there any way to make this be an opaque black background, instead?


On the white background, it makes white be the white transparent background, but black is a nice, deep black (overall I find this less annoying):

transparent-status-item-bg-white

Currently, I'm just using [statusItem setImage:artworkImage] to set the image.

1
Use NSAppearance.El Tomato
On what, the status bar? Interesting—what would that do?SilverWolf
NSAppearance did work wonderfully on an image view inside the status item. Thanks, @ElTomato. (Now I just have to figure out how to get the click action!)SilverWolf
Apparently it doesn't work properly for multiple screens.SilverWolf

1 Answers

1
votes

For some reason, adding a transparent NSView as a subview of the status item's button works wonderfully:

let subview = NSView.init(frame: statusItem!.button!.frame)
statusItem?.button?.addSubview(subview)

Now, I still have no idea why it works.

Edit: This works up to OS X v10.13 High Sierra, but does not work on v10.14 Mojave. It's back to transparency.