我正在开发一个应用程序,其中应用程序的主页具有隐藏细线的白色导航栏,其余页面具有绿色导航栏。到目前为止,我所做的是将主页导航栏的代码放在自己的.swift文件中,但是当我通过主页上的按钮导航到其他页面时(与菜单栏相反) )导航栏仍然设置为白色。我认为这是因为当通过按钮访问时,删除细线的代码会传递到其他页面。如何在Swift中为不同页面撤消发条删除?
这是我的网页应该非常像: Homepage & Module
这实际上是模块页面的样子:Module Page Now
这是我使用的代码 - 不知道是否有人能帮助我弄清楚如何反转代码或者是否有其他解决方案。
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Set navigation bar tint/background colour
self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
// Set Navigation bar Title colour
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.blackColor()]
//Set navigation bar Back button tint colour
self.navigationController?.navigationBar.tintColor = UIColor.blackColor()
//Get Rid of 1px hairline
self.navigationController?.navigationBar.setBackgroundImage(
UIImage(),
forBarPosition: .Any,
barMetrics: .Default)
self.navigationController?.navigationBar.shadowImage = UIImage()
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
// Set navigation bar tint/background colour
self.navigationController?.navigationBar.barTintColor = UIColor(red: 0/255, green: 127/255, blue: 106/255, alpha: 1)
// Set Navigation bar Title colour
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]
//Set navigation bar Back button tint colour
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
//Reverse get Rid of 1px hairline code
/*self.navigationController?.navigationBar.setBackgroundImage(
UIImage(),
forBarPosition: .Any,
barMetrics: .Default)
self.navigationController?.navigationBar.shadowImage = UIImage()*/
}
你是什么意思为“发际线”? –
@AlessandroOrnano与导航栏底部相邻的1px线 – zenpain