美文网首页
Swift3.0 开发macOS应用程序 (9): 关闭、最小化

Swift3.0 开发macOS应用程序 (9): 关闭、最小化

作者: MNode | 来源:发表于2017-02-10 15:07 被阅读208次

Xcode默认窗口中3个按钮的显示位于左上角,如下图

QQ20170210-150158.png

如何做成与Google Browser或者Xcode一样,3个按钮是居中显示的呢?通过mac自带的设置手段达到如下效果,如下图:

QQ20170210-145753.png

其实很简单,首先要在WindowController中设置

        window?.titlebarAppearsTransparent = true
        window?.titleVisibility = .hidden
        window?.styleMask = [.fullSizeContentView,.titled,.resizable,.miniaturizable,.closable]

有时想做成常用软件CleanMyMac一样,title与3个按钮居中对齐,只需获取Titlebar 的高,然后放入一个等高的CustomView,通过将Label与CustomView居中约束即可达到相应效果。

QQ20170210-150944.png

取消toolBar属性内的Separator勾,可以实现这样的效果

QQ20170210-151208.png

隐藏TitleBar请看http://www.jianshu.com/p/c2466c67be32

源码如下:github-->demo

相关文章

网友评论

      本文标题:Swift3.0 开发macOS应用程序 (9): 关闭、最小化

      本文链接:https://www.haomeiwen.com/subject/wrigittx.html