简体   繁体   中英

how do i to make a window(osx) always hover on top of screen

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.

You can change the window's windowLevel (via -setLevel:) to NSFloatingWindowLevel.

[window setLevel:NSFloatingWindowLevel]; 

Documentation is here: Window_Levels

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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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