我很難理解爲什麼下面的代碼不起作用,我想要實現的是在NSView的左上角顯示的圖像,但沒有任何顯示...cocoa - 在NSView中繪製圖像
NSImage *map0 = [NSImage imageNamed:@"map0.png"];
NSRect rect = NSMakeRect(0, 0, 400, 400);
[map0 drawInRect:rect fromRect:NSZeroRect operation:NSCompositeSourceAtop fraction:1.0f];
[map drawRect:rect];
編輯:
map
是一個NSView我想成將圖像繪製成
你能解釋一下最後一行嗎?這個上下文中的map變量是什麼,爲什麼它需要繪製與你的圖像相同的矩形? – Tim
對不起,我忘了說,地圖是NSView ... –