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 navigationBar
using storyboard
but unable to set the image.
Here is the code which perfectly work for me in Swift 3.
Put this in
didFinishLaunchingWithOptions
.And here is the output which I received.
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()
For setting up the background image to whole navigation bar use this cde in swift 3.0,
Hope this will help you.
To set NavigationBar Background Image you can write this:
XCode 8.1 Swift 3.0 iOS 10
from Apple documentation:
Reference: Navigation Bars