Pergunta

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.

Foi útil?

Solução

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top