0
我使用colorWithPatternImage
創建NSColor
在蘋果示例所示它:NSColor colorwithpatternimage描繪的NSView在黑色
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
backgrColor = [[NSColor colorWithPatternImage:[NSImage imageNamed:@"greenfelt"]] retain];
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect {
[backgrColor set];
NSRectFill(dirtyRect);
}
的圖像從相同的例子採取和它的作品出現。當我在我的應用程序中嘗試它時,視圖呈黑色。爲什麼會這樣?
感謝
感謝您的回覆。該視圖是通過IB創建的,並綁定到NSViewController的子類中的相應IBOutlet。添加擴展確實有幫助,但我發現另一個問題,阻止找到圖像。謝謝你指點我正確的方向! – 2011-05-10 04:20:15
@NavaCarmon,另一個問題是什麼? – Jeff 2013-06-11 21:04:38
我不記得確切,但我的猜測是我的應用程序是從捆綁生成的,整個事情是從正確的捆綁中獲取資源...... – 2013-06-12 09:50:42