1、创建tabBarController的图片和文字颜色都是蓝色的 修改图片颜色方法:
var image:UIImage = UIImage(named: "shouye-weixuanzhong")!
var selectedImage:UIImage = UIImage(named: "shouye")!
image = image.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
selectedImage = selectedImage.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
homeVC.tabBarItem.image = image
PS:
public enum UIImageRenderingMode : Int {
case automatic // 根据图片的使用环境和所处的绘图上下文自动调整渲染模式
case alwaysOriginal // 始终绘制图片原始状态,不使用
Tint Color case alwaysTemplate //始终根据Tint Color绘制图片,忽略图片的颜色信息
}
2、修改文字颜色的方式
homeVC.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.red], for: .highlighted) homeVC.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.black], for: .normal)
3、修改原生导航栏上字体颜色
navigationController.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.red]
4、修改原生导航栏的颜色
navigationController.navigationBar.barTintColor = UIColor.yellow
5、修改左右返回按钮颜色
navigationController.navigationBar.tintColor = UIColor.yellow
新手入门,欢迎大家交流讨论