我已经实现了一个自定义滑块单元格,它可以使用滚动条和旋钮的图像进行绘制。现在唯一的障碍是,当我快速拖动旋钮时,图像会变得混乱。我已经发布了一个屏幕截图。
这是代码:
#import "customSliderCell.h"
@implementation customSliderCell
- (void)drawKnob:(NSRect)knobRect {
NSImage * knob = knobImage;
[[self controlView] lockFocus];
[knob
compositeToPoint:NSMakePoint(knobRect.origin.x,knobRect.origin.y+knobRect.size.height)
operation:NSCompositeSourceOver];
[[self controlView] unlockFocus];
}
- (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped {
rect.size.height = 8;
NSRect leftRect = rect;
leftRect.origin.x=0;
leftRect.origin.y=2;
leftRect.size.width = knobrect.origin.x + (knobrect.size.width);
[leftBarImage setSize:leftRect.size];
[leftBarImage drawInRect:leftRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction:1];
NSRect rightRect = rect;
rightRect.origin.x=0;
rightRect.origin.y=2;
rightRect.origin.x = knobrect.origin.x;
[rightBarImage setSize:rightRect.size];
[rightBarImage drawInRect:rightRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction:1];
}
啊,我是如此接近。关于为什么会发生这种情况以及如何解决它的任何帮助将不胜感激,谢谢!