我试图让我的应用程序有更多的“扁平化”感觉,所以我认为隐藏标题栏是个好主意。
然而,实际上 titlebarAppearsTransparent
似乎只是去除了标题栏阴影,并没有使标题栏真正透明。
在使用任何代码修改标题栏之前,
添加如下代码后(开始有更好的感觉),
self.window?.titlebarAppearsTransparent = true
设置背景颜色为白色,
self.window?.backgroundColor = NSColor.whiteColor()
self.window?.titlebarAppearsTransparent = true
这当然不是我想要的。我以为我只是将标题栏透明化为 true
。这是怎么回事?
感谢任何提示或评论,感谢您花时间查看此问题。
最佳答案
尝试添加:
self.window?.styleMask |= NSFullSizeContentViewWindowMask
When set, the content view consumes the full size of the window; it can be combined with other window style masks, but is only respected for windows with a title bar. Using this mask opts in to layer backing. Use the contentLayoutRect or contentLayoutGuide to lay out views underneath the title bar-toolbar area
如果你根本不想保留标题栏,你也可以添加:
self.window?.titleVisibility = NSWindowTitleVisibility.Hidden;
The window hides the title and moves the toolbar up into the area previously occupied by the title.
您可能还想添加此内容以便通过拖动其内容 View 来移动窗口:
self.window?.movableByWindowBackground = YES
A Boolean value that indicates whether the window is movable by clicking and dragging anywhere in its background. The value of this property is YES when the window is movable by clicking and dragging anywhere in its background; otherwise, NO.
关于swift - 窗口标题栏出现透明问题(不是真正透明),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35944792/