The following code worked just fine for setting a custom image as a UINavigationBar background:
let image = UIImage(named:"HeaderBanner-new")
UINavigationBar.appearance().setBackgroundImage(image, for: UIBarMetrics.defaultPrompt)
Since upgrading to Xcode 9, Swift 4, and iOS 11, this code no longer works. All I get is a plain white background in a UINavigationBar.
I also tried moving the code from AppDelegate.swift
and putting it directly into my own custom file UINavgiationController.swift
:
let image = UIImage(named:"HeaderBanner-new")
self.navigationBar.setBackgroundImage(image, for: UIBarMetrics.defaultPrompt)
Still not working. Any ideas what is going on - or ideas for a workaround / hack?
source
share