代码之家  ›  专栏  ›  技术社区  ›  Era

更改窗口按钮的控件色调

  •  0
  • Era  · 技术社区  · 14 年前

    NSGraphiteControlTint . 但下面的代码似乎不起作用。有什么建议吗?

    NSButton *button = [window standardWindowButton:NSWindowCloseButton];
    [[button cell] setControlTint:NSGraphiteControlTint];
    

    当做, 埃里克

    2 回复  |  直到 14 年前
        1
  •  1
  •   Jesús A. Álvarez    14 年前

    [[NSUserDefaults standardUserDefaults] setInteger:NSGraphiteControlTint forKey:@"AppleAquaColorVariant"];
    

    但是,如果您希望它在应用程序第一次启动时工作,则必须在绘制任何UI之前执行,例如 main 打电话之前 NSApplicationMain ,也可以使用的自定义子类 NSApplication ,并在其 -init [super init]

        2
  •  0
  •   dfrankow    14 年前

    代码看起来是正确的。要验证它,可以在单选按钮或按钮上尝试。

    要得到一个看起来像关闭按钮的灰色版本的小按钮,我认为您将不得不使用自定义图形按钮或自定义绘图的您自己的子类。