iOS---iOS13,push后tabbaritem选中颜色变

2021-03-10  本文已影响0人  iOS程序媛ing

解决方法

if (@available(iOS 13.0, *)) {
        self.tabBar.unselectedItemTintColor = TOPIC_AuxiliaryColor;//未选中时文字颜色
        self.tabBar.tintColor = TOPIC_GoldenColor;//选中时文字颜色
        
    } else {
        [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : TOPIC_AuxiliaryColor} forState:UIControlStateSelected];
        [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : TOPIC_GoldenColor} forState:UIControlStateSelected];
        
    }

如不选中情况下文字颜色为灰色,选中后颜色为红色,代码实现如下

if (@available(iOS 13.0, *)) {
        self.tabBar.unselectedItemTintColor = [UIColor GrayColor];//未选中时文字颜色
        self.tabBar.tintColor = [UIColor redColor];//选中时文字颜色
        
    } else {
        [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor redColor]} forState:UIControlStateSelected];
        [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor GrayColor]} forState:UIControlStateNormal];
        
    }
上一篇 下一篇

猜你喜欢

热点阅读