문제

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