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

 

 

 

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