Mac开发之 监听窗口的改变

监听窗口拉伸,进入全屏,即将推出全屏,已经推出全屏,最小化,窗口关闭

观察窗口拉伸

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(screenResize)name:NSWindowDidResizeNotificationobject:nil];

-(void)screenResize{

//NSLog(@"观察窗口拉伸");

//NSLog(@"%.2f===%.2f",self.view.bounds.size.width,self.view.bounds.size.height);

}

即将进入全屏

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(willEnterFull:)name:NSWindowWillEnterFullScreenNotificationobject:nil];

-(void)willEnterFull:(NSNotification*)notification{

NSLog(@"即将全屏");

}

即将推出全屏

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(willExitFull:)name:NSWindowWillExitFullScreenNotificationobject:nil];

-(void)willExitFull:(NSNotification*)notification {

NSLog(@"即将推出全屏");

}

已经推出全屏

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(didExitFull:)name:NSWindowDidExitFullScreenNotificationobject:nil];

-(void)didExitFull:(NSNotification*)notification{

NSLog(@"推出全屏");

}

窗口最小化

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(didMiniaturize:)name:NSWindowDidMiniaturizeNotificationobject:nil];

-(void)didMiniaturize:(NSNotification*)notification{

NSLog(@"窗口变小");

}

窗口即将关闭

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(willClose:)name:NSWindowWillCloseNotificationobject:nil];

-(void)willClose:(NSNotification*)notification{

NSLog(@"窗口关闭");

}

关于Mac开发的随笔记(以下皆是作者随笔)

Mac开发 关于鼠标的事件(隐藏)

Mac开发 NSButton 字体颜色

Mac开发之 文件拖入窗口

Mac开发自定义TitleBar 和设置窗口居中

Mac开发 简单动画

Mac开发 代码实现 发邮箱

Mac开发之 监听窗口的改变

Mac ios开发 URL 转 汉字

Mac开发 给视图设置颜色View,Button等

希望大家多多支持:

此文已由作者授权,转载请注明文章出处

你可能感兴趣的:(Mac开发之 监听窗口的改变)