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


1 answer


OK, I removed the navigation bars and added new ones to the storyboard ... now it only works with app delegation code. It looks like it's just Xcode 6 / Swift, buggy.



+1


source







All Articles