iOS中UIView設(shè)置背景色是
UIView *view= [[UIView alloc]init];
view.backgroundColor = [UIcolor redcolor];
OS X中NSView沒(méi)有backgroundColor這個(gè)屬性焕梅,所以無(wú)法直接設(shè)置
CALayer *viewLayer = [CALayer layer];
NSView *backgroundView= [[NSView alloc]init];
[backgroundView setWantsLayer:YES];
[backgroundView setLayer:viewLayer];
backgroundView.layer.backgroundColor = [NSColor colorWithRed:0.14 green:0.62 blue:0.93 alpha:1.0].CGColor;
[backgroundView setNeedsDisplay:YES];