我正在尝试在mac os中的NSWindow上绘制一些像素(NSRects为1x1),但是当我这样做时,它会随机拍摄一个窗口来绘制它(见下文)。它应该在左侧窗口。
-(void)draw:(NSRect)rect {
NSGraphicsContext *ctx = [[NSGraphicsContext currentContext] graphicsPort];
[NSGraphicsContext saveGraphicsState];
double perlinValue = [[[xValues objectAtIndex:x] objectAtIndex:y] floatValue];
[[NSColor colorWithCalibratedRed:perlinValue green:perlinValue blue:perlinValue alpha:1.0f] set];
NSRectFill(CGRectMake(x, y, 1, 1));
[NSGraphicsContext restoreGraphicsState];
}