Reputation: 2852
I've tried both line bellow but it all cause [UITabBar setUnselectedItemTintColor:]: unrecognized selector sent to instance
[self.tabBar setUnselectedItemTintColor:[UIColor blackColor]];
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor blackColor]];
Any suggestion?
Upvotes: 2
Views: 1499
Reputation: 2201
Try This
if ([[UITabBar appearance] respondsToSelector:@selector(setUnselectedItemTintColor:)])
{
[[UITabBar appearance]setUnselectedItemTintColor:AppYellowColor];
}
else
{
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:AppYellowColor, NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
}
Upvotes: 0
Reputation: 7741
This method is available on iOS 10 only, so it will crash on previous versions. You should check method availability before calling it.
if ([[UITabBar appearance] respondsToSelector:@selector(setUnselectedItemTintColor:)]) {
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor blackColor]];
}
Upvotes: 8