문제

I want to tint my button in drawRect, but cannot find the right setup to tint the image

- the button is borderless, with a grayscale image, which i want to tint

In my NSButton subclass :

- (void)drawRect:(NSRect)dirtyRect{

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

        [[NSColor redColor] set];

    } else {

        [[NSColor blackColor] set];

    }

    NSRectFillUsingOperation(dirtyRect, NSCompositePlusDarker);

    [super drawRect:dirtyRect];
}

올바른 솔루션이 없습니다

다른 팁

Try using setFill:

[[NSColor redColor] setFill];

...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top