1

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

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

在我的 NSButton 子类中:

- (void)drawRect:(NSRect)dirtyRect{

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

        [[NSColor redColor] set];

    } else {

        [[NSColor blackColor] set];

    }

    NSRectFillUsingOperation(dirtyRect, NSCompositePlusDarker);

    [super drawRect:dirtyRect];
}
4

1 回答 1

0

尝试使用setFill

[[NSColor redColor] setFill];

...

于 2014-01-15T20:10:45.483 回答