NSScroller problèmes graphiques / lag
-
05-07-2019 - |
Question
J'ai la sous-classe NSScroller suivante qui crée une barre de défilement avec un bouton blanc arrondi et aucune flèche / emplacement (arrière-plan):
@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 bien, sauf un décalage notable lorsque j'utilise le scroller. Voir cette vidéo:
Je suis confus quant à ce que je fais mal, des suggestions?
La solution
Correction du problème, il suffisait de remplir le rectangle dans drawKnobSlotInRect:
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow