Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change font of back button on uinavigationcontroller

I'm trying to change the font color of the text on my back button in my UINavigationControllerBar

    [[UIBarButtonItem appearance] setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 

gives me this error: [_UIBarItemAppearance setTitleColor:forState:]: unrecognized selector sent to instance 0x69aeb70'

Any help? Thanks!

like image 252
itgiawa Avatar asked Apr 06 '12 07:04

itgiawa


1 Answers

NSMutableDictionary *attributes = [NSMutableDictionary dictionary]; [attributes setValue:[UIColor colorWithRed:(163.0f/255.0f) green:(0.0f) blue:(0.0f) alpha:1.0f] forKey:UITextAttributeTextColor]; [attributes setValue:[UIColor clearColor] forKey:UITextAttributeTextShadowColor]; [attributes setValue:[NSValue valueWithUIOffset:UIOffsetMake(0.0, 0.0)] forKey:UITextAttributeTextShadowOffset]; [[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal]; 

seems to work!

like image 197
itgiawa Avatar answered Nov 11 '22 16:11

itgiawa