Quartz is drawing on a different window
I am trying to draw some pixels (NSRects that are 1x1) on a NSWindow in mac os, but when I do that it randomly pics a window to draw it o开发者_开发问答n (see below). It is supposed to be on the left window.
-(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];
}
精彩评论