UINavigationBar setBackgroundImage in AppDelegate with Swift
I am trying to set a background image to a navbar globally in an App Delegate in Swift. I can get it to work with a separate view controller like this:
var topBar: UINavigationBar!
topBar.setBackgroundImage(UIImage(named: "navbar"), forBarMetrics:
.Default)
But when I try to add the following to the App Delegate, it crashes with an uncaught exception:
UINavigationBar.appearance().setBackgroundImage(UIImage(named:
"navbar"), forBarMetrics: .Default)
+3
source to share