I can’t figure out how to set the font/styling of my NSMenuItems in my NSMenu. I tried the setFont method on the NSMenu but it doesn’t seem to have any effect on the menu items. NSMenuItem doesn’t seem to have a setFont method. I would like for them all to have the same font/style so I would hope there’s just one property I can set somewhere.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- back button text does not change
- iOS (objective-c) compression_decode_buffer() retu
- how to find the index position of the ARRAY Where
相关文章
- 现在使用swift开发ios应用好还是swift?
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- didBeginContact:(SKPhysicsContact *)contact not in
- Custom Marker performance iOS, crash with result “
Actually [NSMenu setFont:] works for all menu items submenus (if last ones doesn't have their own font). Maybe you set attributed title before setting the menu font? Realized it, after writing own procedure to iterate through menu items.
In case you need some custom processing (i.e. change font for not all items, or customize it for different items) here is a simple iterating code:
They can have an attributed title, so you can set an attributed string as title with all it's attributed, font included:
NSMenuItem has support for attributed strings as titles:
Example code:
Documentation: https://developer.apple.com/library/mac/#documentation/cocoa/reference/applicationkit/classes/nsmenuitem_class/reference/reference.html
+ menuBarFontOfSize:
fromNSFont
is your friend here.[NSFont menuBarFontOfSize:12]
to get the default font and set a new size.[NSFont menuBarFontOfSize:0]
.So to only change the
NSMenuItem
color: