【发布时间】:2012-08-01 17:54:29
【问题描述】:
我正在尝试用一种颜色填充我的NSView,但它没有使用我想要的颜色。它只是黑色的。
这是我对 NSView 子类的实现:
#import "OCOvalView.h"
@implementation OCOvalView
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
bgColorValue = [NSColor greenColor];//I WANT IT TO BE FILLED GREEN
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect
{
[bgColorValue set];
[NSBezierPath fillRect:[self bounds]];//BUT IT ENDS UP BLACK!!
}
@end
如果我将[bgColorValue set]; 更改为[[NSColor greenColor] set];,它将起作用,但我想使用如上所示的变量。
如何使填充颜色与bgColorData 的颜色相同?
【问题讨论】:
标签: objective-c macos nsview