I am trying to change the font color on tab bar items. I'm using code from this post:
change tabbar text color,iPhone
My code is as follows:
if ([self.tabBarItem respondsToSelector:@selector(setTitleTextAttributes:)]) {
NSLog(@"yes");
[self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
darkGreen, UITextAttributeTextColor,
nil] forState:UIControlStateNormal];
}
else {
NSLog(@"no");
}
respondsToSelector always returns no, and I'm stuck as to how to fix it. This code block is in viewDidLoad, and the class is a subclass of UITabBarController.
Any ideas?
This method setTitleTextAttributes:
doesn't exists at all, the correct signature of that method is setTitleTextAttributes: forState:
if ([self.tabBarItem respondsToSelector:@selector(setTitleTextAttributes: forState:)]) {
NSLog(@"yes");
[self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
darkGreen, UITextAttributeTextColor,
nil] forState:UIControlStateNormal];
}
else {
NSLog(@"no");
}