美文网首页
iOS---iOS13,push后tabbaritem选中颜色变

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

作者: iOS程序媛ing | 来源:发表于2021-03-10 11:26 被阅读0次

解决方法

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

相关文章

网友评论

      本文标题:iOS---iOS13,push后tabbaritem选中颜色变

      本文链接:https://www.haomeiwen.com/subject/dyaozktx.html