2009-10-22 8 views
2

je la sous-classe NSScroller suivante qui crée une barre de défilement avec un bouton blanc arrondi et sans flèches/fente (arrière-plan):NSScroller glitches graphiques/lag

@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 

Tout cela fonctionne très bien, sauf qu'il ya un noticable décalage quand j'utilise le défilement. Voir cette vidéo:

http://twitvid.com/70E7C

Je suis confus quant à ce que je fais mal, des suggestions?

Répondre

2

Correction du problème, il suffit de remplir le rect dans drawKnobSlotInRect: