我已尝试过两条线,但这一切都导致 [UITabBar setUnselectedItemTintColor:]:无法识别的选择器发送到实例
[self.tabBar setUnselectedItemTintColor:[UIColor blackColor]];
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor blackColor]];
有什么建议吗?
答案 0 :(得分:8)
此方法仅适用于iOS 10,因此在以前的版本中会崩溃。您应该在调用之前检查方法可用性。
if ([[UITabBar appearance] respondsToSelector:@selector(setUnselectedItemTintColor:)]) {
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor blackColor]];
}
答案 1 :(得分:0)
试试这个
if ([[UITabBar appearance] respondsToSelector:@selector(setUnselectedItemTintColor:)])
{
[[UITabBar appearance]setUnselectedItemTintColor:AppYellowColor];
}
else
{
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:AppYellowColor, NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
}