Any way to use a SymbolEffect in an NSButton

Examples of using SymbolEffect in AppKit all seem to be in NSImageView, and look through APIs it seems that the only way to apply those effect animations outside of SwiftUI is indeed in an NSImageView.

I have a NSStatusItem where I'm using an SF Symbol in the NSStatusBarButton title (subclass of NSButton) and was trying to figure out if there was a way to use a SymbolEffect there.

If the image of an NSButton uses (used) an NSImageView under the hood, that used to hidden in the buttons cell. Seeing how cells seem to be inaccessible now, perhaps there isn't a NSImageView in there these days anyway. Can NSStatusBarButton titles be provided by a custom view, oh I'm guessing the deprecated view property is still operational, but if I'm trying to release to the Mac App Store, that as equally off-limits as an NSButtonCell would have been. Is there a non-deprecated way that will let me ship to the App Store?

Post not yet marked as solved Up vote post of jpmhouston Down vote post of jpmhouston
351 views

Replies

I've just faced the same issue. I can now solve this only by adding an NSImageView as a subview in the button, and apply the animations there. But I also have to deal with image transparency now - when I switch to the other window, the image stays fully opaque, while NSButton.image's default implementation decreases image's alpha in this case. So my implementation doesn't seem right, although it works...