我有以下NSScroller子类,该子类创建带有圆形白色旋钮且没有箭头/插槽(背景)的滚动条:

@implementation IGScrollerVertical

- (void)drawKnob
{
    NSRect knobRect = [self rectForPart:NSScrollerKnob];
    NSRect newRect = NSMakeRect(knobRect.origin.x, knobRect.origin.y, knobRect.size.width - 4, knobRect.size.height);
    NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:7 yRadius:7];
    [[NSColor whiteColor] set];
    [path fill];
}

- (void)drawArrow:(NSScrollerArrow)arrow highlightPart:(int)flag
{
    // We don't want arrows
}

- (void)drawKnobSlotInRect:(NSRect)rect highlight:(BOOL)highlight
{
    // Don't want a knob background
}
@end


一切正常,除了使用滚动条时有明显的滞后。观看此视频:

http://twitvid.com/70E7C

我对自己做错了什么感到困惑,有什么建议吗?

最佳答案

解决了该问题,只需要在drawKnobSlotInRect中填充矩形即可:

10-08 07:54