If you assign images in Interface Builder and set the image property on UIImageView to image@2x.png , for example, iOS will not know that this is a 2x high resolution image. In fact, on the retina screen, iOS will look for an image named image@2x @2x.png . Since he will not find it, he will set the scale factor of the image to 1.0.
The contentMode property (only โmodeโ in Xcode) decides whether any image scaling will comply with UIImageView restrictions. You might want to set the Aspect Fit mode to get a high resolution image for scaling as needed for retina and non-retina displays. In general, the image will be displayed as shown in Interface Builder.
If you use UIImage imageNamed or a similar function to upload an image and simply specify image (where "image.png" does not exist but " image@2x.png " does), then iOS will actually find the image on the screen without a retina, although the scale factor will be 1.0. As before, you need to scale it to fit your idea. The image will work fine on the retina device, and the zoom factor will be set to 2.0, since iOS first looks for the โ2xโ image, and it doesn't matter if another file exists or not.
This is from the Apple documentation on imageNamed :
On a device running iOS 4 or later, the behavior is identical if the device screen is 1.0. If the screen has a scale of 2.0, this method first searches for an image file with the same file name with the suffix @ 2x added to it. For example, if the file name, it first searches for the @ 2x button. If it finds 2x, it loads this image and sets the scale property of the returned UIImage to 2.0. Otherwise, it loads the unmodified file name and sets the scale property 1.0. See the iOS Application Programming Guide for more information on supporting images with different scale factors.
If at all possible, you really should include images of the retina and not the retina. Using images with a higher resolution than necessary will adversely affect memory and performance.
source share