Macos NSButton在drawRect中着色图像
我想在drawRect中着色我的按钮,但找不到正确的设置来着色图像 -按钮是无边框的,带有灰度图像,我想对其着色 在我的NSButton子类中:Macos NSButton在drawRect中着色图像,macos,cocoa,nsimage,nsbutton,nsbuttoncell,Macos,Cocoa,Nsimage,Nsbutton,Nsbuttoncell,我想在drawRect中着色我的按钮,但找不到正确的设置来着色图像 -按钮是无边框的,带有灰度图像,我想对其着色 在我的NSButton子类中: - (void)drawRect:(NSRect)dirtyRect{ if ([self.cell mouseDownFlags] == 0) { [[NSColor redColor] set]; } else { [[NSColor blackColor] set]; }
- (void)drawRect:(NSRect)dirtyRect{
if ([self.cell mouseDownFlags] == 0) {
[[NSColor redColor] set];
} else {
[[NSColor blackColor] set];
}
NSRectFillUsingOperation(dirtyRect, NSCompositePlusDarker);
[super drawRect:dirtyRect];
}
尝试使用
setFill
:
[[NSColor redColor] setFill];