iOS13之前使用的是:
設定item title顔色
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor redColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateSelected、UIControlStateNormal];
設定圖檔
vc.tabBarItem.image = [[UIImage imageNamed:@"xxx"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc.tabBarItem.selectedImage = [[UIImage imageNamed:@"xxx"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
設定選中 及預設的顔色
在iOS13運作項目時發現 在從A頁面Push B頁面隐藏tabbar 後傳回 點選tabbarItem時 title的顔色被重置成系統色值
解決:
*目前我的方法隻能解決設定選中的顔色 沒法設定預設顔色
設定圖檔的方法不變
設定title 選中顔色使用
tabVC.tabBar.tintColor = [UIColor redColor];
因為預設的情況下我們的項目圖檔也是灰色的 是以目前不用設定預設顔色
看到此貼後有人有更好的解決方案 希望能分享...
有兄弟在文章下方給出了設定預設顔色的方法
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor yellowColor]];