我有以下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
这一切都很好,除了使用滚动条时有明显的延迟。观看此视频:
我很困惑我做错了什么,有什么建议吗?
答案 0 :(得分:2)
解决了这个问题,只需要在drawKnobSlotInRect中填充rect: