NSImage + transparency?

I'm not sure if this is the right thing to ask ... but I want to basically whitewash the NSImage, or lower its opacity ... (sort of like an "inactive" icon in Finder? Something like that)

What's the easiest way to achieve this?

I tried the example given here ( NSImage transparency ) but it definitely did NOT work for me ...

(Btw, NSImage will be in ImageAndTextCell

if it matters ...)

+3


source to share


1 answer


All you have to do is paint the image with an alpha less than 1.0

. In your implementation, ImageAndTextCell

just use something like this in the method -drawWithFrame:inView:

:



[image drawInRect:someRect 
         fromRect:NSZeroRect 
        operation:NSCompositeSourceOver //this draws the image using the alpha mask
         fraction:0.5];

      

+7


source







All Articles