滑动回根视图控制器时,大型导航栏背景颜色变得清晰

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
    }
    
}

我在 viewWillAppearviewDidLoad

更新

这是两种状态的截图:

刷卡前: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
    }

}

这篇关于滑动回根视图控制器时,大型导航栏背景颜色变得清晰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
Dropbox Files.download does not start when number of files in folder is gt; 1000(当文件夹中的文件数为1000时,Dropbox Files.Download不会启动)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)