简体   繁体   中英

How to create a custom NSMenuItem

Well, I have quite a basic question which I can't seem to find an answer to. I followed this guide to create a StatusBar menu, which works great... However, I would like to add a custom NSMenuItem containing custom stuff. As example such as the sound slider, or the switch user account row ect.

How can I do that?

Even links to tutorials are welcome.

In most cases, you'll create a custom view containing the slider or whatever else you want to appear in the menu item. Then you call setView: on the NSMenuItem in question.

For more details, check this article from Apple's documentation: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MenuList/Articles/ViewsInMenuItems.html

只需使用setView:方法NSMenuItem

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