Simon.
Simon.

Reputation: 1896

iOS, support retina display

When supporting retina, and non-retina displays you would provide the image.png & [email protected] with relating resolutions.

I understand that iOS will decide which image to use based on the user's device. However, I'm using the images via code, not storyboard.

self.imagePortrait = [UIImage imageNamed:@"image.png"];

Even though I have not specified [email protected], will iOS make use of it?

Upvotes: 0

Views: 75

Answers (1)

Ben Zotto
Ben Zotto

Reputation: 71008

In this case yes. UIImage's -imageNamed: is smart enough to choose the correct resource. (And note that the suffix is @2x, not @X2.)

From the docs:

If the screen has a scale of 2.0, this method first searches for an image file with the same filename with an @2x suffix appended to it.

Other methods (like -initWithContentsOfFile:) do not have these smarts built in.

Upvotes: 1

Related Questions