NSTabView与背景颜色 [英] NSTabView with background color

查看:534
本文介绍了NSTabView与背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如其他地方所讨论的,NSTabView没有setBackgroundColor方法,并且对NSTabView进行子类化,并使用drawRect来控制它不再工作,因为它不会绘制前10%,位于分段控制按钮下面。 p>

现在我有点惊讶的工作量,我不得不解决这个问题;请参阅





我想知道我是否走错了路径。如何做到这一点更好&更简单:




  • NSSegmentStyleTexturedSquare似乎让我得到一个半透明的分段控件。这意味着我需要做额外的工作来隐藏任何边框线(线240,253)。




    • 去做这个 ?也就是说否定其透明度?


    • 或者我可以使用实际/原始分段选择按钮吗?



  • 我发现我需要的颜色 - 例如[NSColor windowBackgroundColour]没有设置为有用的我硬编码他们(行87,94)。




    • 有更好的方法吗?


  • 我发现我需要一堆蓬松的方法来保持同步(第128行,134行等)。




      <
    • 我发现模仿重新缩放的聪明性意味着我需要持续关注分区控制框并删除/调整它的大小。即使这样 - 它不如原来的好。




      • 是有比157行更好的方法 - 即听到关于调整大小?

      • 当焦点从窗口移开时,segementControl会变暗 - 不像真正的McCoy 。




        • 可以轻易避免吗?有没有一个便宜的方式来跟踪这个?


      • 或者这是错误的方法 - 我应该只关注一个透明的孔 - 让NSTabViewItem背景 ?但在任何情况下 - 然后我仍然有与Segedmented COntrol框的问题 - 或者有一种方法,使其成为默认值。




        • 当尝试这个 - 我被卡在顶部的20-30像素被绘制在'真实的'窗口背景颜色 - 这是'透明' - 因此颜色不会一直运行到顶部或后面



        反馈赞赏 - 因为这感觉如此遥远/次优的简单的事情 -
        非常感谢。布朗尼点为黑客/分叉github代码:) :) :)一行运行代码说超过一千字。



        Dw。

        解决方案

        PSMTabBarControl可能是最好的解决方法。我已经创建了几个自定义选项卡视图,但可可不能很好地与这个控件。 PSMTabBarControl已更新,以支持Xcode 4. https://github.com/ciaran/psmtabbarcontrol


        As discussed elsewhere, NSTabView does not have a setBackgroundColor method and subclassing NSTabView and using an drawRect to control it does no longer work - as it does not paint the top 10%, the bit just below the segmented control button.

        Now I am a bit surprised by the amounts of work arounds I had to do solving this; see

        and am wondering if i went down the wrong path. And how to do this better & simpler:

        • The NSSegmentStyleTexturedSquare seems to yield me a semi-transparent segmented Control. Which means I need to do extra work to hide any bezel lines (line 240, 253).

          • 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 ?

        • I find that the colours I need - like the [NSColor windowBackgroundColour] are not set to anything useful (i.e. that one is transparent) -- so right now I hardcode them (lines 87, 94).

          • Is there a better way to do this ?
        • I find I need a boatload of fluffy methods to keep things in sync ( line 128, 134, etc).

          • can this be avoided ?
        • I find that mimicking the cleverness on rescaling means I need to keep a constant eye on the segemented Control box and remove/resize it. And even then - it is not quite as good as the original

          • is there a better way to do this than line 157 -- i.e. hear about resizing ? Rather than do it all the time ?
        • The segementControl fades dark when focus is removed from the window - unlike the real McCoy.

          • can that easily be prevented ? is there a cheap way to track this ?
        • Or is this the wrong approach - and should I focus on just a transparent hole here - and let the NSTabViewItem draw a background ? But in any case - then I still have the issue with the Segemented COntrol box - or is there than a way to make that be the default again.

          • 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.

        Feedback appreciated - as this feels so far off/suboptimal for such a simple things -- Thanks a lot. Brownie points for hacking/forking the github code :) :) :) As a line of running code says more than a thousand words.

        Dw.

        解决方案

        PSMTabBarControl is probably the best workaround for you. I have created several custom tab views, but cocoa does not play well with this control. PSMTabBarControl has been updated to support Xcode 4. https://github.com/ciaran/psmtabbarcontrol

        这篇关于NSTabView与背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆