Reputation: 3802
I have already added all images in three format like test.png, [email protected], [email protected] for IOS in resources folder, still on big resolution screen like ipad it shows default one test.png.
I am not getting why this is happening. Am I missing something from code side.
EDIT :
sorry my mistake. my question was wrong.it shows different image but in small size.
i tried 3 different images with same name having @2x,@3x extension. so i come to know that in ipadPro(9.7 inch) it shows @3x image while in iphone5(which lowest screen resolution simulator in my mac) it shows @ 2x image.
so how could we decide which screen resolution will take which image?and how can we decide their size.?
Upvotes: 1
Views: 223
Reputation: 79776
Depending on the device, you accomplish this by multiplying the number of pixels in each image by a specific scale factor. A standard resolution image has a scale factor of 1.0
and is referred to as an @1x
image. High resolution images have a scale factor of 2.0
or 3.0
and are referred to as @2x
and @3x
images.
Suppose you have a standard resolution
@1x
image that’s100px x 100px
, for example. The@2x
version of this image would be200px × 200px
. The@3x
version would be300px × 300px
.
iPhone X, iPhone 8 Plus, iPhone 7 Plus, and iPhone 6s Plus support 3x resolution. iPhone 8, iPhone 7, iPhone 6/6s and iPhone 5s/5c support 2x resolution. All other iPhone devices support 1x resolution.
Consider following sample set of images for view with size 10 points and how do iOS system selects device resolution specific image.
@3x -> 3 * (10px x 10px) = (30px x 30px) // iPhone X, iPhone 8 Plus, iPhone 7 Plus, and iPhone 6s Plus
@2x -> 2 * (10px x 10px) = (20px x 20px) // iPhone 8, iPhone 7, iPhone 6/6s and iPhone 5s/5c
@1x -> 1 * (10px x 10px) = (30px x 30px) // All other iPhone devices
Note: You don't need to do any code (setup) to assign device resolution specific images. Just add images for all (1x, 2x and 3x) types of resolution in your image set. iOS system automatically chooses/selects device resolution specific image from the set of image.
Look at this document of Apple: Image Size and Resolution
Here is nice tutorial for easy understading: DESIGNING FOR THE NEW IPHONE SCREEN RESOLUTIONS
Upvotes: 2