Can anyone explain how to add an image as your navigation bar's background in swift?
            Asked
            
        
        
            Active
            
        
            Viewed 138 times
        
    -1
            
            
        - 
                    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 Answers
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)
- 
                    Does this work for a standard NavBar View Controller? I tried your code and it came back that myNavbar is an unresolved identifier. Thank you. – Octavio Antonio Cedeño Nov 28 '14 at 14:34
 
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().
        Gabriel Jáuregui
        
- 36
 - 4