开发者

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];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜