When we need to download an image from some URL and show it on two kinds of devices -- Retina (with 2x image) and regular device -- Should we have two different image URLs to handle this?
For the images in the resource bundle we are keeping both xyz.png and [email protected] and its working fine.
For images we are fetching from server do we need to have separate image URLs for both these kind of images and cache them locally with the same naming convention (xyz.png and [email protected])?
Please throw some light here.
To accommodate high resolution/retina displays, you'll want to use an image that's 1280 pixels wide, which is what's referred to as “2x”. While the graphic will still display on the website at 640 pixels wide, you are doubling the pixel density by using an image that's double the size.
Retina-ready websites are websites that utilise modern technology to display high-resolution images on devices that have high definition (HD) displays, such as the many tablets and smartphones, and some modern laptops, macbooks and desktop PCs.
To make your website retina-ready, use Scalable Vector Graphics (SVG) whenever possible. SVG is an XML-based graphic format that presents images in high quality. SVG images can be viewed in Internet browsers that use XML or be displayed on mobile phones in SVGB or SVGT file formats.
WordPress retina images The term "retina images" is thrown around a lot, but basically it means they are high resolution. High resolution images are also used in the PC world on 4k monitors, Windows 10 laptops, and tablets.
You can check if the device has a high-resolution retina display and based on that download a different image. Don't bother for photos and stuff that you'd scale anyway for interface size.
You can create the scaled version of the downloaded image with
UIImage *image = //download...
image=[UIImage imageWithCGImage:[image CGImage] scale:2.0 orientation:UIImageOrientationUp];
Keep in mind that a scaled 100x100 image will become a 50x50 points image (with 2.0 scale).
Check first if you have a retina display
BOOL retina = NO;
if([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
retina = [[UIScreen mainScreen] scale] == 2.0 ? YES : NO;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With