首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何设置NSSegmentedControl背景图片?

如何设置NSSegmentedControl背景图片?
EN

Stack Overflow用户
提问于 2013-06-04 16:01:31
回答 1查看 1.1K关注 0票数 2

我想设置NSSegmentedControl背景图像,而不是图标图像。我子类化NSSegmentedCell并重写drawSegment: inFrame: withView: function.But this works bad.How我能做到吗?

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

EN

回答 1

Stack Overflow用户

发布于 2013-06-04 16:43:55

子类化和重写drawSegment: inFrame: withView可以很好地工作

代码语言:javascript
复制
- (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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16912625

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档