正如这篇文章的标题中提到的,我想设置一个子类的边框(颜色和宽度),该子类NSTableCellView在基于视图的NSTableView. 我尝试了以下
self.layer.borderColor = [[NSColor greenColor] CGColor];
self.layer.borderWidth = 3.0;
我将代码放入initWithCoder并awakeFromNib没有获得所需的结果。backgroundColor可以在drawRect-Method 中更改。有人可以指出我正确的方向吗?
谢谢
编辑
这是我使用的解决方案NSFrameRect
- (void)drawRect:(NSRect)dirtyRect
{
[NSGraphicsContext saveGraphicsState];
[[NSColor lightGrayColor]set];
NSFrameRect([self bounds]);
[NSGraphicsContext restoreGraphicsState];
}