objective-c – 如何激活没有标题栏的窗口

前端之家收集整理的这篇文章主要介绍了objective-c – 如何激活没有标题栏的窗口前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我可以发送消息makeKeyAndOrderFront:使窗口处于活动状态.但是,如果我将它发送到没有标题栏的窗口,它不会激活它.有没有办法制作一个没有标题栏活动的窗口?

解决方法

您需要在NSWindow子类中覆盖 -canBecomeKeyWindow以返回YES.

根据文档:

Attempts to make the window the key window are abandoned if this method returns NO. The NSWindow implementation returns YES if the window has a title bar or a resize bar,or NO otherwise.

猜你在找的cocoa相关文章