MAC OSX - 系统关闭缩小全屏按钮换位置

效果图
  1. 去掉系统titleBar合并到下面
    在MainMenu.xib选中Window,勾选属性Full Size Content View,实现的效果就是titleBar和下面的view合并到一起。
    用下面这行代码效果是一样的:
self.window.styleMask = self.window.styleMask | NSWindowStyleMaskFullSizeContentView;
  1. 全部代码
- (void)createWindowBtn {
    //将titleBar和下面的view合并到一起
    self.window.styleMask = self.window.styleMask | NSWindowStyleMaskFullSizeContentView;
    //设置为点击背景可以移动窗口
    [self.window setMovableByWindowBackground:YES];
    //设置标题栏透明
    self.window.titlebarAppearsTransparent = YES;
    //隐藏窗口标题
    self.window.titleVisibility = NSWindowTitleHidden;
    
    NSButton *closeBtn = [self.window standardWindowButton:NSWindowCloseButton];
    NSButton *miniaturizeBtn = [self.window standardWindowButton:NSWindowMiniaturizeButton];
    NSButton *zoomBtn = [self.window standardWindowButton:NSWindowZoomButton];
    [self.leftMenuView addSubview:closeBtn];
    [self.leftMenuView addSubview:miniaturizeBtn];
    [self.leftMenuView addSubview:zoomBtn];
    
    //布局,如果用frame写死,系统按钮可能会移到窗口左下方
    [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftMenuView).offset(17);
    }];
    [miniaturizeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftMenuView).offset(17);
    }];
    [zoomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.leftMenuView).offset(17);
    }];

}

参考:
https://www.jianshu.com/p/ff299c351ffd
https://www.jianshu.com/p/620914e3ed11

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 13,902评论 1 32
  • 写在前面的话 在Mac开发的过程中,会有这样的需求:去掉系统自带的titleBar,具体效果类似QQ这样的应用: ...
    雅雅克阅读 7,570评论 1 4
  • ¥开启¥ 【iAPP实现进入界面执行逐一显】 〖2017-08-25 15:22:14〗 《//首先开一个线程,因...
    小菜c阅读 11,894评论 0 17
  • 更好的阅读体验,请到个人博客阅读: iOS中的系统转场 请忽略标题,😂,本文记录的是对下图所示的Kind, Pre...
    CaryaLiu阅读 7,239评论 0 1
  • 国内自定义View的文章汗牛充栋,但是,即便是你全部看完也未必掌握这一知识(实际上,我也看了很多,但是一旦涉及自定...
    SnowDragonYY阅读 5,563评论 3 36

友情链接更多精彩内容