1
votes

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.

example image

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);
}
1
NSDrawThreePartImage is usually the preferred way of doing this. You should probably post your drawRect: implementation.kperryua
Added. Not much there though.Jane

1 Answers

3
votes

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