方法1:在appdelegate中设置
///全局设置导航栏以及左右item的颜色和大小属性---->此方法需要在appDelegate中调用
func appdelegateConfigNavi() {
UINavigationBar.appearance().barTintColor = UIColor.white//navibar的背景渲染色
UINavigationBar.appearance().tintColor = UIColor.red//渲染色
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 18),NSAttributedStringKey.foregroundColor: UIColor.black]
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 15),NSAttributedStringKey.foregroundColor: UIColor.black], for: UIControlState.normal)
}
方法2: 在每一个自定义的页面中修改,记得一定要在viewwillappear中设置
///设置navigationBar的背景选染色
self.navigationController?.navigationBar.barTintColor = UIColor.white
///标题title属性
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: isFour ? UIColor.white : UIColor.black]
//左右BarButtonItem属性
self.navigationItem.rightBarButtonItem?.setTitleTextAttributes([NSAttributedStringKey.font: UIFont.systemFont(ofSize: 15), NSAttributedStringKey.foregroundColor: UIColor.red], for: .normal)
方法3:自定义--->自定义一个View, 设置类似导航栏效果
本文介绍三种iOS应用中导航栏的定制方法:全局配置、单页面设置及自定义视图方案,帮助开发者灵活调整导航栏样式。

551

被折叠的 条评论
为什么被折叠?



