1、OS X中NSView没有backgroundColor这个属性,所以无法直接设置:
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、监听window的拖动之后的frame
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenResize) name:NSWindowDidMoveNotification object:nil];
- (void)screenResize
{
// NSLog(@"聊天窗口的移动:%@", NSStringFromRect([DDMainWindowController instance].window.frame));
//处理自己的逻辑
}
网友评论