简体   繁体   English

如何在Cocoa中制作未装饰的窗户?

[英]How can I make an undecorated window in Cocoa?

I like to create a Cocoa window without any chrome whatsoever. 我喜欢创建一个没有任何铬的可可窗口。 The only thing the user should see is what I draw. 用户唯一要看的就是我画的东西。

I've discovered I can create a custom NSView but does this have to be in an NSWindow to display? 我发现我可以创建自定义NSView,但这是否必须在NSWindow中显示? If not, how can I display it without putting it in an NSWindow? 如果没有,如何显示它而不将其放在NSWindow中? If it does have to be in an NSWindow, how do I stop the window from drawing a title bar and other chrome? 如果确实必须在NSWindow中,如何停止窗口绘制标题栏和其他镶边?

I've discovered I can create a custom NSView but does this have to be in an NSWindow to display? 我发现我可以创建自定义NSView,但这是否必须在NSWindow中显示?

Yes. 是。

If it does have to be in an NSWindow, how do I stop the window from drawing a title bar and other chrome? 如果确实必须在NSWindow中,如何停止窗口绘制标题栏和其他镶边?

Use NSBorderlessWindowMask when you create your window. 创建窗口时,请使用NSBorderlessWindowMask (Assuming you aren't using a custom subclass of NSWindow, this means not creating the window instance in a nib. If you want to lay out your view hierarchy in a nib, do that in a top-level custom view, then load the nib and set that view as the window's content view.) (假设您未使用NSWindow的自定义子类,这意味着不在笔尖中创建窗口实例。如果要在笔尖中布局视图层次结构,请在顶级自定义视图中执行此操作,然后加载笔尖并将该视图设置为窗口的内容视图。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM