2
我想设置NSSegmentedControl
背景图像不是图标image.I子类NSSegmentedCell
并重写drawSegment: inFrame: withView:
函数。但这种方法很糟糕。我该怎么做?如何设置NSSegmentedControl背景图片?
更新: 我想设置半直角暗色或浅色背景图像。
我想设置NSSegmentedControl
背景图像不是图标image.I子类NSSegmentedCell
并重写drawSegment: inFrame: withView:
函数。但这种方法很糟糕。我该怎么做?如何设置NSSegmentedControl背景图片?
更新: 我想设置半直角暗色或浅色背景图像。
子类化和压倒一切的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中正确设置了分段控件的单元类?
+1我想你的答案足以解决问题。 –
我想设置半直角暗色或浅色背景图像,而不仅仅是将图像添加到背景。 – gohamgx
从原来的问题中不清楚。请更新问题以解释实际问题。 –