開発
Load image for retina device
will
Generally, developers can include additional “@2x” images for retina iOS devices, which are the double size compared with normal images. For instance, for “bar.png”, we can include “[email protected]” in the project for retina device.
In the code
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bar.png"]];
The iOS will choose the right image for you.
However, when we want to download the image programming. We use
CGFloat scale = [UIScreen mainScreen].scale; //2.0 is retina device, and 1.0 is the normal device [[UIImage alloc] initWithCGImage:[after CGImage] scale:scale orientation:UIImageOrientationUp];
Reference:
http://stackoverflow.com/questions/3289286/retina-display-and-uiimage-initwithdata