如何获得NSStatusItem的框架 [英] How to get frame for NSStatusItem
本文介绍了如何获得NSStatusItem的框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将NSStatusItem
的框架添加到可可的状态栏中后,是否可以获取它?启动我的应用程序后,我正在向系统状态栏中添加一个项目,并想知道它的位置.
Is it possible to get the frame of a NSStatusItem
after I've added it to the status bar in Cocoa? When my app is launched, I am adding an item to the system status bar, and would like to know where it was positioned, is possible.
推荐答案
如果您在状态项上设置了自定义视图:
If you have set a custom view on the status item:
NSRect statusRect = [[statusItem view] frame];
NSLog(@"%@", [NSString stringWithFormat:@"%.1fx%.1f",statusRect.size.width, statusRect.size.height]);
否则,我认为使用可用的和记录的API是不可能的.
Otherwise I don't think it's possible using the available and documented APIs.
合并的注释.
这篇关于如何获得NSStatusItem的框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文