我想设置NSSegmentedControl
的背景图像,而不是图标图像。我对NSSegmentedCell
进行子类化并重写drawSegment: inFrame: withView:
函数。但这行不通。我该怎么做呢?
更新:我想设置半矩形的深色或浅色背景图像
子类化和重写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];
}
你还试了什么?
您是否在"界面生成器"中正确设置了分段控件的单元格类?