简体   繁体   中英

swift: gray color in bar

I have NavigationViewController with white navigation bar color. When I go from firstViewController to secondViewController I see gray color in my navigation bar. I want to remove this gray color. How to fix it?

firstViewController :

在此处输入图片说明

go to secondViewController :

在此处输入图片说明

secondViewController :

在此处输入图片说明

How to remove this:

在此处输入图片说明

my code:

override func viewDidLoad() {
        super.viewDidLoad()

        if #available(iOS 11.0, *) {
            self.navigationController?.navigationBar.prefersLargeTitles = true
            self.navigationItem.largeTitleDisplayMode = .always
            self.navigationController?.navigationBar.shadowImage = UIImage()
            self.navigationController?.navigationBar.backgroundColor = UIColor.white
        } else {
            // Fallback on earlier versions
        }
}

您需要将isTranslucent属性设置为true

  self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.navigationBar.barTintColor = .white
self.navigationController?.navigationBar.shadowImage = image
self.navigationController?.navigationBar.setBackgroundImage(image, for: .default)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM