2

我想设置NSSegmentedControl背景图像而不是图标图像。我将其子类化NSSegmentedCell并重写drawSegment: inFrame: withView:函数。但这很糟糕。我该怎么做?

更新:我想设置半矩形深色或浅色背景图像。

4

1 回答 1

1

子类化和覆盖drawSegment: inFrame: withView工作正常

- (void)drawSegment:(NSInteger)segment inFrame:(NSRect)frame withView:(NSView *)controlView
{
    NSImage* image = [NSImage imageNamed:NSImageNameBonjour];
    [image drawInRect:frame fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
    [super drawSegment:segment inFrame:frame withView:controlView];    
}

你还尝试了什么?
您是否在 Interface Builder 中正确设置了分段控件的单元格类?

于 2013-06-04T08:43:54.580 回答