窗口标题栏出现透明问题(不是真的透明) [英] Window title bar appears transparent issue (Not really transparent)

查看:574
本文介绍了窗口标题栏出现透明问题(不是真的透明)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使我的应用程序具有更平坦"的感觉,因此我认为隐藏标题栏是个好主意.

I am trying to make my app have more 'flat' feel so I think it is a good idea to hide the title bar.

但是,实际上titlebarAppearsTransparent似乎仅删除标题栏阴影,而不能使标题栏真正透明.

However, in reality titlebarAppearsTransparent seems only remove the title bar shadow but not make the title bar truly transparent.

在使用任何代码修改标题栏之前,

Before using any code to modify the title bar,

添加以下代码(开始时会有更好的感觉),

After adding the following code (starting have a better feel),

self.window?.titlebarAppearsTransparent = true

将背景色设置为白色

    self.window?.backgroundColor = NSColor.whiteColor()
    self.window?.titlebarAppearsTransparent = true

这当然不是我想要的.我以为我只是将标题栏变成了true透明.这是怎么回事?

This is certainly not what I want. I thought I just turned the title bar transparent to true. What is going on here?

感谢任何提示或评论,感谢您的宝贵时间来查看此问题.

Any hint or comment is appreciated and thanks for your time viewing this question.

推荐答案

尝试添加:

self.window?.styleMask |= NSFullSizeContentViewWindowMask

设置后,内容视图将占用整个窗口的大小;它 可以与其他窗口样式蒙版结合使用,但仅受尊重 用于带有标题栏的窗口.使用此遮罩选择加入图层 后盾.使用contentLayoutRect或contentLayoutGuide进行布局 标题栏-工具栏区域下方的视图

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

如果您根本不想保留标题栏,还可以添加:

If you don't want to keep the title bar at all, you can also added:

self.window?.titleVisibility = NSWindowTitleVisibility.Hidden;

该窗口隐藏标题并将工具栏上移到该区域 以前被标题占据.

The window hides the title and moves the toolbar up into the area previously occupied by the title.

您可能还想添加此内容,以便通过拖动其内容视图来移动窗口:

You might also wanted to add this in order to move the window by dragging its content view:

self.window?.movableByWindowBackground = YES

一个布尔值,指示窗口是否可移动 在其背景中的任意位置单击并拖动.这个的价值 当通过单击和拖动来移动窗口时,属性为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.

这篇关于窗口标题栏出现透明问题(不是真的透明)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆