Sometimes, we want to set the NSView's background color to clear color, and you maybe use the code:
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
NSColor *bgColor = [NSColor clearColor];
[bgColor set];
}
if you do like this, the background will be black,not clear,so how to do it?
The way is you don't need to use the drawRect: method,just need to call the method:
- (BOOL)isOpaque
{
retuen YES;// or NO
}
Reference:http://www.cocoachina.com/bbs/read.php?tid=85775
http://www.cocoachina.com/bbs/read.php?tid-45122.html
Thanks,
Blues