1着茸、OS X中NSView沒有backgroundColor這個(gè)屬性腾誉,所以無法直接設(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];
2找筝、監(jiān)聽window的拖動(dòng)之后的frame
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenResize) name:NSWindowDidMoveNotification object:nil];
- (void)screenResize
{
// NSLog(@"聊天窗口的移動(dòng):%@", NSStringFromRect([DDMainWindowController instance].window.frame));
//處理自己的邏輯
}