我想设置NSSegmentedControl
背景图片而不是图标图像。我将NSSegmentedCell
子类化并重写drawSegment: inFrame: withView:
函数。但是这样做不好。我该怎么做?< / p>
更新: 我想设置半直的深色或浅色背景图像。
答案 0 :(得分: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中正确设置了分段控件的单元类?