开发者

NSView background image composed of 3 different files

开发者 https://www.devze.com 2023-01-11 07:51 出处:网络
I\'m trying to set a background image of an NSView. (Actually an NSScrollView.) At 开发者_开发知识库the moment I\'m subclassing drawRect: and I\'m using NSDrawThreePartImage to draw the image but ther

I'm trying to set a background image of an NSView. (Actually an NSScrollView.) At 开发者_开发知识库the moment I'm subclassing drawRect: and I'm using NSDrawThreePartImage to draw the image but there are a few things that are not correct whenever I start scrolling.

NSView background image composed of 3 different files

Are there better ways to draw the images?

- (void)drawRect: (NSRect)dirtyRect
{
    dirtyRect.size.height -= 18; //Moving the image up a bit for future subclassing of NSScroller.
    NSDrawThreePartImage(dirtyRect, viewLeftCap, viewFill, viewRightCap, NO, NSCompositeSourceOver, 1, YES);
}


If you want to redraw the whole view, you should be using [self bounds], not the rect passed into your -drawRect: method.

0

精彩评论

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