我已经使用了 largeNavigationBar
并且没关系,直到我滑回根视图控制器并且大导航以令人讨厌的方式获得清晰的颜色.代码如下:
I have used largeNavigationBar
and it's ok until i swipe back to root view controller and large navigation gets clear color in a nasty way. Here's the code:
func largeNavigationTitle() {
self.navigationController?.view.backgroundColor = VVUtility.navigationBarColor()
let productTitle = request?.product?.name
self.navigationItem.title = "(productTitle ?? " ")".localized()
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white, NSAttributedStringKey.font : VVUtility.normalFontWithPlusSize(increaseSize: -2.0)]
if #available(iOS 11.0, *) {
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.backgroundColor = VVUtility.splashBackGroundColor()
self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white, NSAttributedStringKey.font : VVUtility.normalFontWithPlusSize(increaseSize: 0.0)]
} else {
// Fallback on earlier versions
}
}
我在 viewWillAppear
和 viewDidLoad
更新
这是两种状态的截图:
刷卡前:imgur.com/a/ZcSOrov
刷卡时:imgur.com/a/DYeeot8
试试这个.它应该将根视图控制器的导航栏颜色设置为您想要的颜色:
Try this. It should set your root View controller's navigationBar's colour to the one you wanted:
func largeNavigationTitle() {
self.navigationController?.view.backgroundColor = VVUtility.navigationBarColor()
//add the two lines below
self.navigationController?.navigationBar.barTintColor = VVUtility.navigationBarColor()
self.navigationController?.navigationBar.isTranslucent = false
let productTitle = request?.product?.name
self.navigationItem.title = "(productTitle ?? " ")".localized()
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white, NSAttributedStringKey.font : VVUtility.normalFontWithPlusSize(increaseSize: -2.0)]
if #available(iOS 11.0, *) {
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.backgroundColor = VVUtility.splashBackGroundColor()
self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white, NSAttributedStringKey.font : VVUtility.normalFontWithPlusSize(increaseSize: 0.0)]
} else {
// Fallback on earlier versions
}
}
这篇关于滑动回根视图控制器时,大型导航栏背景颜色变得清晰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!