سؤال

I am trying to fill an NSRect in a subview with a translucent color. I am using:

[[NSColor colorWithCalibratedWhite:1 alpha:0.5]set];

But the alpha value doesn't make it transparent but just darker. Using an alpha value of 0 simply gives black. I have used this code many times before and i do not know why it is not working.

Thank you in advance, Ben.

هل كانت مفيدة؟

المحلول

The color appears darker because the context itself is not transparent, you're seeing the blacks bleed through behind the transparency. You need to use this operation:

NSRectFillUsingOperation(theRect, NSCompositeSourceOver);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top