iOS13 UITabBar title颜色还原 不正确

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]];

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章