This is a pretty simple fix. You will have to edit the BASequenceControl.m file or you can duplicate the class and rename it.
The line that is causing the problem is in drawRect:
it basically draws the grey arrow across the entire background of the control. Creating that nice gradient in the empty space.
[passiveSegmentImage drawInRect:CGRectMake(-passiveSegmentImage.size.width, 0,
w + 2 * passiveSegmentImage.size.width, h)];
You can change it to:
[passiveSegmentImage drawInRect:CGRectMake(0, 0,
w, h)];
Now you have to tell the control that it should not be opaque. Update the initializers like this.
- (void)awakeFromNib {
_selectedSegmentIndex = -1;
[self setOpaque:NO];
[super awakeFromNib];
}
- (id)init {
if ((self = [super init])) {
[self setOpaque:NO];
_selectedSegmentIndex = -1;
}
return self;
}
This is pretty quick and dirty, you could potentially make this settable with a property. Then submit a pull request to BaseAppKit, but I'll leave that to you. Here is a gist that you can copy and paste directly in BASequenceControl.m to fix the overhang.
https://gist.github.com/4632686
Edit: Make sure that you are using init
as the initializer and then setFrame:
(I'm not really sure why initWithFrame:
wasn't overridden in the class.)
BASequenceControl *control = [[BASequenceControl alloc] init];
[control setFrame:CGRectMake(0, 0, 300, 40)];
Green background for dramatic effect
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…