use*_*125 2 colors uinavigationcontroller swift
我在尝试将 navigationBar.barTintColor 更改为白色时遇到了困难。奇怪的是,所有其他颜色都有效,但不是白色!
self.navigationController!.navigationBar.barTintColor = UIColor.whiteColor()
Run Code Online (Sandbox Code Playgroud)
上面的线不仅仅适用于白色。
甚至尝试使用背景图像。还是一样。任何其他颜色都可以,但白色不行!!白色总是被浅灰色取代......
请指教我哪里出错了...
谢谢。
试试这个代码:
在您的 viewDidLoad 中:
title = "Some Title"
UIApplication.shared.statusBarStyle = .default
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.isTranslucent = true
//Line under NavigationBar
let barView = UIView(frame: CGRect(x:0, y:(UINavigationController().navigationBar.frame.height + UIApplication.shared.statusBarFrame.height), width:view.frame.width, height:0.6))
barView.backgroundColor=UIColor.red // set any colour you want..
navigationController?.navigationBar.addSubview(barView)
//Title Colour
navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.red]
Run Code Online (Sandbox Code Playgroud)
笔记:
上面的代码适用于任何背景颜色......如果你希望导航栏是绿色......将你的视图背景颜色设置为绿色......
| 归档时间: |
|
| 查看次数: |
1332 次 |
| 最近记录: |