正如在其他地方所讨论的,NSTabView没有一个setBackgroundColor方法和子类NSTabView,并且使用drawRect来控制它不再工作--因为它没有绘制前10%的位置,这个位正好在分段控制按钮的下方。
现在,我对我不得不做的大量工作感到惊讶,你看
https://github.com/dirkx/CustomizableTabView/blob/master/CustomizableTabView/CustomizableTabView.m
我想知道我是不是走错路了。以及如何做得更好&更简单:
- is there a better way to do this ? I.e. negate its transparency ?
- or is there a way I can use the actual/original segmented choise button ?
- Is there a better way to do this ?
- can this be avoided ?
那么好。
- is there a better way to do this than line 157 -- i.e. hear about resizing ? Rather than do it all the time ?
当焦点从窗口移除时,
- can that easily be prevented ? is there a cheap way to track this ?
- when trying this - I get stuck on the top 20-30 pixels being drawn in the 'real' windows background colour - which is 'transparent' - and hence the colour will not run all the way to the top or behind the segment bar and up to the bezel - but instead stop some 8 pixels below the bottom of the segment controls.
反馈很受欢迎--因为对于这样简单的事情来说,这感觉很不理想--非常感谢。用于黑客/分叉github代码的Brownie点:) :)作为一行运行的代码,需要超过1000个单词。
Dw。
发布于 2012-01-09 16:58:20
PSMTabBarControl可能是您的最佳解决方案。我已经创建了几个自定义选项卡视图,但可可并不能很好地使用此控件。PSMTabBarControl已被更新,以支持Xcode 4. https://github.com/ciaran/psmtabbarcontrol
发布于 2015-06-01 21:29:48
您是否尝试过设置其基础CALayer的背景色?(如果还没有,则通过设置wantsLayer =YES将其设置为层背景视图。)
发布于 2015-10-03 08:49:07
如果您的情况可以容忍某些脆弱性,那么一个非常简单和快捷的方法是将NSTabView子类划分为子类,并手动调整项子视图的框架。这使每个项目都有一个无缝的黄色背景:
- (void)drawRect:(NSRect)dirtyRect {
static const NSRect offsetRect = (NSRect) { -2, -16, 4, 18 };
NSRect rect = self.contentRect;
rect.origin.x += offsetRect.origin.x;
rect.origin.y += offsetRect.origin.y;
rect.size.width += offsetRect.size.width;
rect.size.height += offsetRect.size.height;
[[NSColor yellowColor] set];
NSRectFill(rect);
[super drawRect:dirtyRect];
}NSTabView指标的未来更改显然是一个问题,因此您自己承担风险吧!
https://stackoverflow.com/questions/8090641
复制相似问题