Husyn Husyn - 8 days ago 11
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

Trying setting "self.navigationItem.titleView" property

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

Update:

Try this, instead of setting in UINavigationBar()

let navBackgroundImage:UIImage! = UIImage(named: "<navigationBarImage>")
self.navigationController?.navigationBar.setBackgroundImage(navBackgroundImage,
                                                            for: .default)