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.