Eyes, JAPAN Blog > Load image for retina device

Load image for retina device

will

この記事は1年以上前に書かれたもので、内容が古い可能性がありますのでご注意ください。

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.

bar

bar.png

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

  • このエントリーをはてなブックマークに追加

Comments are closed.