I've created an iTunes like subclass of NSScroller, however if both the horizontal and vertical scrollers are visible in an NSScrollView or NSTableView I'm left with an ugly white square in the lower right corner. Anyone has a clue on where to add my custom drawing to fill that in with something prettier?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Ok, I think I have the solution(s).
Either you tell the scrollview not to draw its background, in that case anything below it will fill the corner.
Or, which is what I did, you override the scrollview's drawRect method with the following:
- (void)drawRect:(NSRect)rect{ [super drawRect: rect]; if([self hasVerticalScroller] && [self hasHorizontalScroller]){ NSRect vframe = [[self verticalScroller]frame]; NSRect hframe = [[self horizontalScroller]frame]; NSRect corner; corner.origin.x = NSMaxX(hframe); corner.origin.y = NSMinY(hframe); corner.size.width = NSWidth(vframe); corner.size.height = NSHeight(hframe); // your custom drawing in the corner rect here } }