本文介绍了当导航回根视图控制器时,大导航栏backGround会获得清晰的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿伙计们我已经使用了 largeNavigationBar
,直到我刷回根视图控制器并且大导航以令人讨厌的方式获得清晰的颜色。这是代码:
Hey guys i've 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
中回忆 largeNavigationTitle()
更新
这里是两种状态的屏幕截图:刷卡前
:刷卡时
:
here is screenshot of two states:before swiping: imgur.com/a/ZcSOrovwhen swiping: imgur.com/a/DYeeot8
推荐答案
请尝试在AppDelegate.swift中调用方法
Please try to call method in AppDelegate.swift
func application(_ application: UIApplication,
willFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
}
这篇关于当导航回根视图控制器时,大导航栏backGround会获得清晰的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!