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?
In this case yes. UIImage's -imageNamed:
is smart enough to choose the correct resource. (And note that the suffix is @2x
, not @X2
.)
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.