Perhaps try NSWindow's setOpaque:
and you also need to set the window's background color with a transparent color (setBackgroundColor:
)
Here is my quick sample I just did:
custom NSView named myView :
-(void)drawRect:(NSRect)dirtyRect
{
[[NSColor windowBackgroundColor] set]; // Using the default window colour,
dirtyRect.size.width /= 2;
NSRectFill(dirtyRect); // Only draw the part you need.
}
Next I set a window's contentView an instance of myView. I did it in IB but you can manually set it via setContentView
.
And I configured the window like this :
[myWin setOpaque:NO]; //Tells the window manager that the window might have transparent parts.
[myWin setBackgroundColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.0]]; //Tells the window to use a transparent colour.
And this is what I get.
So like I said, you need to tell the window to use an invisible colour as background, then redraw the parts you actually do need drawn.