【问题标题】:NSButton tinting image in drawRectNSButton在drawRect中着色图像
【发布时间】:2014-01-15 14:45:30
【问题描述】:

我想在 drawRect 中为我的按钮着色,但找不到正确的设置来为图像着色

- 按钮是无边框的,带有灰度图像,我想对其进行着色

在我的 NSButton 子类中:

- (void)drawRect:(NSRect)dirtyRect{

    if ([self.cell mouseDownFlags] == 0) {

        [[NSColor redColor] set];

    } else {

        [[NSColor blackColor] set];

    }

    NSRectFillUsingOperation(dirtyRect, NSCompositePlusDarker);

    [super drawRect:dirtyRect];
}

【问题讨论】:

    标签: macos cocoa nsimage nsbutton nsbuttoncell


    【解决方案1】:

    尝试使用setFill

    [[NSColor redColor] setFill];
    

    ...

    【讨论】:

      猜你喜欢
      • 2013-02-16
      • 1970-01-01
      • 2018-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-07
      • 2011-12-18
      • 1970-01-01
      相关资源
      最近更新 更多