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.
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.
精彩评论