How to change the font color / Text Color of the UIBarButtonItem on navigation bar How to change the font color / Text Color of the UIBarButtonItem on navigation bar ios ios

How to change the font color / Text Color of the UIBarButtonItem on navigation bar


Check this out :-

  UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithTitle:@"Title" style:UIBarButtonItemStyleBordered target:nil action:nil];[cancel setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor],  UITextAttributeTextColor,nil] forState:UIControlStateNormal];


Just an iOS7 Update with Modern Obj-C Syntax:

[barButtonItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateNormal];


UITextAttributeTextColor //Is deprecated on iOS 7. 

This code is used for change the text color from from appearance proxy.

[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];


matomo