I have a UINavigationController
image that I'm setting in the App Delegate
's didFinishLaunchingWithOptions
like this:
var image: UIImage = UIImage(named: "Header")!
UINavigationBar.appearance().setBackgroundImage(image, forBarMetrics: .Default)
The Header
is the file in the Assets.xcassets
with the 2x and 3x size images. I took out the 1x size because I read it was necessary and it wasn't making a difference either way. On an iPhone 6 the image is perfectly centered. While on a iPhone5 it's more to the right. When I put the above code in the viewDidLoad method in my file, I get a blank header.
I also tried resizing the image:
var image: UIImage = UIImage(named: "Header")!
image.resizableImageWithCapInsets(UIEdgeInsetsMake(0, -260, 0, 0))
UINavigationBar.appearance().setBackgroundImage(image, forBarMetrics: .Default)
I even plugged in random numbers to see if anything changes and it doesn't.
Anyone have any idea what to do?
I referenced these links:
UPDATE
Centering the UIImage on the NavigationBar still doesn't work on the iPhone5.