Mac小知识点

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));
    //处理自己的逻辑
    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容