I am currently using Swift in Xcode 6, Beta 5. I am trying to remove the title bar, or any visible difference between the title bar and the actual content. If I enable "Unified title and toolbar" in the Attributes Inspector on a Window, nothing visibly happens. I have already left the title out.
When no title is entered, the title bar will still be distinguishable because of the border line and background difference with the rest of the window, separating it from the actual content.
我目前在Xcode 6, Beta 5中使用Swift。我试图删除标题栏,或者标题栏和实际内容之间的任何可见差异。如果我在窗口上的属性检查器中启用“统一标题和工具栏”,那么什么都不会发生。我已经把题目漏掉了。当没有输入标题时,标题栏仍然可以区分,因为边框线和背景与窗口其他部分的不同,将它与实际内容分开。
An excellent example would be the current Yosemite, OS X 10.10, Notes app. No title bar is visible or distinguishable, just the Close, Minimise and Resize buttons as seen here.
一个很好的例子是目前的优胜美地,OS X 10.10, Notes应用。没有标题栏是可见的或可区分的,只有关闭、最小化和调整按钮,如图所示。
I have searched and visited other posts, but to no to little avail.
Those mentioned hiding the title bar altogether, but I wouldn't know how to manually re-add the Close, Minimise and Resize buttons properly, meaning they would look correct, no actual, sneaky image replacements and connections with the menu bar Close, Minimise and Resize functions.
我搜索并访问了其他的职位,但毫无用处。那些提到的隐藏标题栏,但我不知道如何手动重新添加关闭,最小化和调整按钮,意味着他们看起来正确,没有实际的,偷偷的图像替换和连接的菜单栏关闭,最小化和调整功能。
6 个解决方案
#1
39
The new window style mask NSFullSizeContentViewWindowMask
added in OS X 10.10 will do the trick.
在OS X 10.10中添加的新的窗口样式掩码nsfullsiecontentviewwindowmask将实现这个功能。
self.window.titleVisibility = NSWindowTitleVisibility.Hidden;
self.window.titlebarAppearsTransparent = YES;
self.window.styleMask |= NSFullSizeContentViewWindowMask;
发布说明
#2
18
For 10.10+, you can use these:
对于10.10+,您可以使用以下工具:
window.titlebarAppearsTransparent = true
window.movableByWindowBackground = true
There was an official sample project for window appearance in Yosemite. You might wanna check it out.
在优胜美地有一个官方的窗口外观示例项目。你可能想看看。
#3
15
For Swift 3 :-
斯威夫特3:-
self.window.titleVisibility = .hidden
self.window.titlebarAppearsTransparent = true
self.window.styleMask.insert(.fullSizeContentView)
#4
11
You can use these:
您可以使用这些:
override func viewDidAppear() {
super.viewDidAppear()
self.view.window?.titlebarAppearsTransparent = true
self.view.window?.movableByWindowBackground = true
}
#5
1
I don't have enough reputation to comment on Ranfei Songs answer, but running on OSX 10.12 the syntax for the titleVisibility is slightly different, instead of this:
我没有足够的声誉来评论Ranfei歌曲的答案,但是在osx10.12上运行的标题可见性的语法略有不同,不是这样的:
self.window.titleVisibility = NSWindowTitleVisibility.Hidden;
you'll need to use NSWindowTitleHidden instead, so updating Ranfei's code would result in you need to specify this like this:
您将需要使用NSWindowTitleHidden,因此更新Ranfei的代码会导致您需要这样指定:
self.window.titleVisibility = NSWindowTitleHidden;
self.window.titlebarAppearsTransparent = YES;
self.window.styleMask |= NSFullSizeContentViewWindowMask;
#6
1
Update Sept. 2017, taget 10.11:
2017年9月更新,taget 10.11:
override func viewDidAppear() {
super.viewDidAppear()
self.view.window?.titleVisibility = .hidden
self.view.window?.titlebarAppearsTransparent = true
self.view.window?.styleMask.insert(.fullSizeContentView)
}
#1
39
The new window style mask NSFullSizeContentViewWindowMask
added in OS X 10.10 will do the trick.
在OS X 10.10中添加的新的窗口样式掩码nsfullsiecontentviewwindowmask将实现这个功能。
self.window.titleVisibility = NSWindowTitleVisibility.Hidden;
self.window.titlebarAppearsTransparent = YES;
self.window.styleMask |= NSFullSizeContentViewWindowMask;
发布说明
#2
18
For 10.10+, you can use these:
对于10.10+,您可以使用以下工具:
window.titlebarAppearsTransparent = true
window.movableByWindowBackground = true
There was an official sample project for window appearance in Yosemite. You might wanna check it out.
在优胜美地有一个官方的窗口外观示例项目。你可能想看看。
#3
15
For Swift 3 :-
斯威夫特3:-
self.window.titleVisibility = .hidden
self.window.titlebarAppearsTransparent = true
self.window.styleMask.insert(.fullSizeContentView)
#4
11
You can use these:
您可以使用这些:
override func viewDidAppear() {
super.viewDidAppear()
self.view.window?.titlebarAppearsTransparent = true
self.view.window?.movableByWindowBackground = true
}
#5
1
I don't have enough reputation to comment on Ranfei Songs answer, but running on OSX 10.12 the syntax for the titleVisibility is slightly different, instead of this:
我没有足够的声誉来评论Ranfei歌曲的答案,但是在osx10.12上运行的标题可见性的语法略有不同,不是这样的:
self.window.titleVisibility = NSWindowTitleVisibility.Hidden;
you'll need to use NSWindowTitleHidden instead, so updating Ranfei's code would result in you need to specify this like this:
您将需要使用NSWindowTitleHidden,因此更新Ranfei的代码会导致您需要这样指定:
self.window.titleVisibility = NSWindowTitleHidden;
self.window.titlebarAppearsTransparent = YES;
self.window.styleMask |= NSFullSizeContentViewWindowMask;
#6
1
Update Sept. 2017, taget 10.11:
2017年9月更新,taget 10.11:
override func viewDidAppear() {
super.viewDidAppear()
self.view.window?.titleVisibility = .hidden
self.view.window?.titlebarAppearsTransparent = true
self.view.window?.styleMask.insert(.fullSizeContentView)
}