Setting different backgrounds for nsview
I'm trying to set custom background for an NSView. I ne开发者_JAVA百科ed different backgrounds to be set based on some action. So i created 2 CAlayers for this view and trying to fill it using colorWithPatternImage.Is this a right method? If not, how can i do it?
Regards,
LS Developer
You could subclass the view that you want, and in its drawRect: method do something like
- (void)drawRect:(NSRect)dirtyRect
{
// Colour the background
[[NSColor orangeColor] set];
NSFillRect (dirtyRect);
// Now draw the parent
[super drawRect:dirtyRect];
}
精彩评论