Husyn Husyn - 1 year ago 187
iOS Question

NavigationBar background image for iOS 10 XCode 8.1 Swift 3.0

How to set the background image for this specific settings? iOS10 and XCode8.1?
I tried everything below:

UINavigationBar.appearance().setBackgroundImage(UIImage(named: "navigationBg")!.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .stretch), for: .default)
UINavigationBar.appearance().setBackgroundImage(UIImage(named: "navigationBg")! , for: .any, barMetrics: .default)
UINavigationBar.appearance().setBackgroundImage(UIImage(named: "navigationBg")! , for: .default)

I'm able to set the color of navigation bar using storyboard but unable to set the image.

Answer Source

Trying setting "self.navigationItem.titleView" property

Reference : how-to-put-an-image-as-the-navigation-bar-title


Try this, instead of setting in UINavigationBar()

let navBackgroundImage:UIImage! = UIImage(named: "<navigationBarImage>")
                                                            for: .default)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download