设置Tabbar字体颜色

不废话,直接上代码

func setTabBarTitleColor() {
        if #available(iOS 13.0, *) {
            UITabBar.appearance().tintColor = UIColor.red
            UITabBar.appearance().unselectedItemTintColor = UIColor.black
        } else {
            UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor : UIColor.black], for: .normal)
            UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor : UIColor.red], for: .selected)
        }
    }

你可能感兴趣的:(设置Tabbar字体颜色)