1

I have 2 NSButtons on a NSVisualEffectView. The first buttons image is the system NSEnterFullScreenTemplate image. The image on this first button is translucent.

On the second button I have an image that I imported in Assets.xcassets. On this second button the image is not translucent (it stays white).

How can I make this image also translucent?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
user2403221
  • 435
  • 1
  • 3
  • 12
  • Have you tried subclassing NSButton? Adding a subview - an NSVisualEffectView - that is the same size as the button? –  Apr 29 '17 at 13:45
  • Not yet, I figured since it works for the NSEnterFullScreenTemplate image I maybe missed something to get it to work with a custom image – user2403221 Apr 29 '17 at 14:03
  • Ok. One time I added a UITabBar to a view and found the blur over a collection view went from blurring an image to all gray. (That's when I discovered the benefits of CoreImage!) It probably wouldn't take much time to implement my suggestion - but the downside is only buttons have the blur. Good luck! –  Apr 29 '17 at 14:07

1 Answers1

1

By using the template setting on NSImage:

button.image.isTemplate = true

Oskar
  • 3,625
  • 2
  • 29
  • 37
  • 1
    thanks a lot that worked! Is this also possible for NSTextField? – user2403221 Apr 29 '17 at 15:33
  • `NSTextField` can be made vibrant by setting the `textColor` to `NSColor.labelColor` or `NSColor.secondaryLabelColor`. For more information on how to achieve vibrancy with `NSVisualEffectView`, see the WWDC 2014 Session 220: https://developer.apple.com/videos/play/wwdc2014/220/ – Oskar Apr 29 '17 at 17:31