Actually [NSMenu setFont:] works for all submenus of menu items (if the latter do not have their own font). Maybe you set the attribute name before setting the menu font? I realized this by writing my own procedure for repeating menu items.
If you need some custom processing (i.e. changing the font for not all elements or adjusting it for different elements), here is a simple iterative code:
@implementation NSMenu (MenuAdditions) - (void) changeMenuFont:(NSFont*)aFont { for (NSMenuItem* anItem in self.itemArray) { NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:aFont forKey:NSFontAttributeName]; anItem.attributedTitle = [[[NSAttributedString alloc] initWithString:anItem.title attributes:attrsDictionary] autorelease]; if (anItem.submenu) [anItem.submenu changeMenuFont:aFont]; } } @end
source share