iOS Tab 自定义字体颜色
let navVC = BGNavigationController(rootViewController: viewController)
navVC.tabBarItem = UITabBarItem(title: title,
image: image.withRenderingMode(.alwaysOriginal),
selectedImage: selectedImage.withRenderingMode(.alwaysOriginal))
let attributes = [NSAttributedString.Key.foregroundColor: redColor]
let normalAttributes = [NSAttributedString.Key.foregroundColor: UIColor("#bcbcbc")]
navVC.tabBarItem.setTitleTextAttributes(attributes,for: UIControl.State.selected)
navVC.tabBarItem.setTitleTextAttributes(normalAttributes,for: UIControl.State.normal)
addChild(navVC)
这个时候发现 tab 字体颜色初始化时正常的。当点击push新的页面以后回来发现字体颜色又变成默认颜色
这个时候要设置 属性
tabBar.tintColor