這裏是我到目前爲止的代碼(在抽籤RECT):繪製到NSImage中的子類的NSView
// Drawing code here.
NSLog(@"%@", [[NSBundle mainBundle] pathForResource:@"NoiseBGMainView" ofType:@"jpg"]);
NSURL *pathToBGImage = [[NSURL alloc] initWithString:[[NSBundle mainBundle] pathForResource:@"NoiseBGMainView" ofType:@"jpg"]];
NSImage *NoiseBGMainView = [[NSImage alloc] initWithContentsOfURL:pathToBGImage];
[NoiseBGMainView drawInRect:[self bounds] fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
而且圖像不畫......我不知道什麼是錯的事。
您是否證明'noiseBGMainView'不是'nil'? – 2010-02-05 03:53:40
我該如何檢查? – nanochrome 2010-02-05 04:21:03
NSLog它,就像你做URL一樣。 – 2010-02-05 04:27:13