Question

Here I have an image, backgroundTest1@2x.png, that is 640 x 128, with the red portion being 320 x 64.

enter image description here

But when I set the image like so:

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"backgroundTest1@2x.png"] forBarMetrics:UIBarMetricsDefault];

I get only red in the navigation bar: enter image description here

What's going on here and what size and name should I be using in my iOS 7 / retina only app? If the '@2x' should be included, then how come 320 x 64 is the image size that 'works'?

Was it helpful?

Solution

You don't need the @2x.png as the system takes care of picking the correct images for you based on the -[UIScreen scale] (png hasn't been need since iOS 4 either). See the docs (+[UIImage imageNamed:]) for more info!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top