large Navigation Bar backGround gets clear color when swiping back to root viewController(滑动回根视图控制器时,大型导航栏背景颜色变得清晰)
本文介绍了滑动回根视图控制器时,大型导航栏背景颜色变得清晰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用了 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
}
}
这篇关于滑动回根视图控制器时,大型导航栏背景颜色变得清晰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
织梦狗教程
本文标题为:滑动回根视图控制器时,大型导航栏背景颜色变得清晰
基础教程推荐
猜你喜欢
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
