我如何使窗口(osx)始终悬停在屏幕顶部
我试图制作一个只有一个窗口的 osx 应用程序,并且它始终位于屏幕顶部。 有人知道如何实现它吗?谢谢。
i trying to make a osx application that just have one window and it will always on the top of screen.
anyone knows how to achieve it? thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将窗口的 windowLevel (通过 -setLevel:)更改为 NSFloatingWindowLevel。
文档位于:Window_Levels
You can change the window's windowLevel (via -setLevel:) to NSFloatingWindowLevel.
Documentation is here: Window_Levels
“在顶部”是指您不希望窗口被遮挡,即使有不同的应用程序处于活动状态?在这种情况下,一种方法是从 Interface Builder 中的 NSPanel 模板开始,选中“实用程序”选项,然后取消选中“停用时隐藏”。
By "on the top", do you mean you do not want your window to be obscured, even if a different app is active? In that case, one way is to start with the NSPanel template in Interface Builder, check the "Utility" option, and uncheck "Hide on Deactivate".