我想使用NSSlider来控制分机。设备。因为分机。设备速度很慢,滑块应显示NSProgressIndicator WITHIN ITK,直到设备达到滑块指定的值。 但是没有显示条形和旋转器(旋钮保持默认外观)。有什么建议吗?
@implementation SubclassedNSSliderCell
-(void)drawKnob:(NSRect)knobRect
{
[spinner setFrame:knobRect]; // as suggested by jtbandes
[super drawKnob:knobRect]; // keep the default knob
[spinner drawRect:knobRect]; // draw the spinner on top
}
-(void)drawBarInside:(NSRect)frame flipped:(BOOL)flipped
{
// stick with default bar
[super drawBarInside:frame flipped:flipped];
}
-(BOOL)_usesCustomTrackImage
{
return YES;
}
// default stuff here...
-(id)init // nothing interesting here...
{
if ((self = [super init]))
{
spinner = [[NSProgressIndicator alloc] initWithFrame:
NSMakeRect(0.f, 0.f, 20.f, 20.f)];
[spinner setStyle:NSProgressIndicatorSpinningStyle];
[spinner startAnimation:self];
}
return self;
}
@end
编辑:此版本最终显示旋钮内的微调器。但是当滑块移动时,微调器会停止动画。我放弃了......
-(void)drawKnob:(NSRect)knobRect
{
[super drawKnob:knobRect];
[[self controlView] addSubview:spinner];
[spinner setFrame:knobRect];
}