I want to set full image on UINavigationBar
, for this I have:
@2x image (640 x 128)
@3x image (960 x 192)
Below Screenshot is the
Create a resizeable image. So the image will be scaled vertically and horizontally to fit the navigation bar including the status bar.
For Swift 3:
if let image = UIImage(named: "imagefile") {
let backgroundImage = image.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
self.navigationController?.navigationBar.setBackgroundImage(backgroundImage, for: .default)
}
or
if let image = UIImage(named: "imagefile") {
let backgroundImage = image.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
UINavigationBar.appearance().setBackgroundImage(backgroundImage, for: .default)
}