-1

Can anyone explain how to add an image as your navigation bar's background in swift?

Fabio Cardoso
  • 1,181
  • 1
  • 14
  • 37
  • possible duplicate of [Changing the UINavigationBar background image](http://stackoverflow.com/questions/7764309/changing-the-uinavigationbar-background-image) – ColinE Nov 28 '14 at 15:55
  • As this is fundamentally the same question as the Obj-C equivalent, I've updated the referenced question and voted for this one to be closed. – ColinE Nov 28 '14 at 15:56

2 Answers2

1

See this question for the answer in Objective-C:

Changing the UINavigationBar background image

Which translates to:

myNavbar.setBackgroundImage(UIImage(named: "logo.png"), forBarMetrics: .Default)
Community
  • 1
  • 1
ColinE
  • 68,894
  • 15
  • 164
  • 232
1

ColinE answer is correct, is just that your navigation bar isn't called myNavbar.

You can try using:

self.navigationController?.navigationBar.setBackgroundImage(UIImage(named: "logo.png"), forBarMetrics: .Default)

inside the viewDidLoad().