NSImage +透明度?

Dr.*_*eon 3 cocoa transparency objective-c opacity nsimage

我不确定这是否是正确的要求...但我想要的基本上是"粉饰"NSImage,或者降低其不透明度 ......(在Finder中有点像"不活跃"的图标?类似的东西)

实现这一目标的最简单方法是什么?

我已经尝试过这里显示的例子(NSImage透明度),但它绝对不适合我......

(顺便说一句,NSImage将会出现ImageAndTextCell,如果这有任何区别......)

Rob*_*ger 7

您需要做的就是使用小于的alpha绘制图像1.0.在您的实现中ImageAndTextCell,只需在-drawWithFrame:inView:方法中使用以下内容:

[image drawInRect:someRect 
         fromRect:NSZeroRect 
        operation:NSCompositeSourceOver //this draws the image using the alpha mask
         fraction:0.5];
Run Code Online (Sandbox Code Playgroud)