views:

2741

answers:

1
[MenuItemFont setFontSize:20];
[MenuItemFont setFontName:@"Helvetica"];
//I'm trying to change the color of start (below item)
MenuItem *start = [MenuItemFont itemFromString:@"Start Game" 
                                        target:self 
                                      selector:@selector(startGame:)];
MenuItem *help = [MenuItemFont itemFromString:@"Help"
                                       target:self 
                                     selector:@selector(help:)];
Menu *startMenu = [Menu menuWithItems:start, help, nil];
[startMenu alignItemsVertically];
[self add:startMenu];
+3  A: 
MenuItemFont *start =  [MenuItemFont itemFromString:@"Start Game" 
                                             target:self 
                                           selector:@selector(startGame:)];

[start.label setRGB:0 :0 :0]; // Black menu item

Label is a property of MenuItemFont, a subclass of MenuItem, so you lose it during the implicit cast to MenuItem.

Alternatively, you could do:

[((MenuItemFont *)start).label setRGB:0 :0 :0]

(but that's ugly, and startMenu will take a MenuItemFont with no complaints).

Keep in mind that the colors are for the most part hardcoded in MenuItemFont, so calling 'setIsEnabled' will set the colors back to grey or white. This happens around line 239 of MenuItem.m if you need to tweak it. If I get around to making a patch to expose this functionality on MenuItemFont (assuming it's not already in the pre-.7.1 sources) I'll update my post.

JustinB