如何获得一个两行工具栏,如Mail.app和Xcode? [英] How can I get a two-row toolbar like in Mail.app and Xcode?

查看:252
本文介绍了如何获得一个两行工具栏,如Mail.app和Xcode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中的NSToolbar之后添加一个第二行,它仍然是标题栏的一部分。例如,Mail在NSToolbar下面有一条细的灰色分隔线,下面有一些额外的项目。非常具体地,当窗口进入全屏模式时,第二个行在系统菜单栏下滑动时保持附着到标题栏。 Xcode有类似的故事。

I'm trying to add a "second row" after my NSToolbar in my app, that remains part of the title bar. As an example, Mail has a thin gray divider line below the NSToolbar with some extras items below that. Very specifically, when the window is put into fullscreen mode, that second "row" stays attached to the title bar as it slides down under the system menu bar. Xcode has a similar story.




我试着将我的NSWindow设置为纹理,并将我的第二行控件直接放在窗口的内容视图中。虽然这在窗口模式下大部分看起来是正确的,但当它们在全屏模式下滑动时,这些控件当然不会出现在工具栏上。那么如何实现Mail和Xcode做同样的行为呢?我已经查看了很多工具栏自定义代码,但没有一个真正涵盖这个特定的情况。

I tried setting my NSWindow to textured and placing my second row controls directly in the content view of the window. While this mostly looks correct in windowed mode, those controls of course won't appear attached to the toolbar when it slides down in fullscreen mode. So how can I achieve the same behavior that Mail and Xcode do? I've looked at a lot of toolbar customization code but none of them really cover this specific case.


推荐答案

我需要做的是调用 [NSToolbar setFullScreenAccessoryView:] 在我的工具栏下面的视图。这导致我的目标的行为。请参阅 NSToolbar文档 a>表示此方法。

What I needed to do was call [NSToolbar setFullScreenAccessoryView:] on the view below my toolbar. This results in the behavior I was aiming for. See the NSToolbar documentation for this method.

这篇关于如何获得一个两行工具栏,如Mail.app和Xcode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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