iphone - How to control images for Retina Display?
My app will download a image and display it into a UIImageView.
The image is quite large, say 600 * 600 and the UIImageView's size is 100 * 100. So when the image is displayed, I set the UIImageView to scale it t开发者_运维技巧o fit.
My question is
For iPhone 3Gs, I understand the image is scaled to 100 * 100 directly and displayed in UIImageView.
But what about iPhone 4? When I do imageView.image = image, will iOS automatically scale the image to 200 * 200 first and then display it in 100 * 100 imageView?
I mean should I do anything extra to make sure that the Retina display is adapted?
Thanks
In this case, no, you needn't do anything particular. If your UIImageView is well configured (scale to fit, as it seems you've done), an iPhone4 will display your image scaled at 200x200 pixels in a 100x100 points UIImageView. No need either to download a different "whatever@2x.png" image.
You don't have to do anything specific here. Your image will be scaled appropriately by UIKit and in fact it's the UIImageView
which will be affected by the Retina display, not your image. You specify a size of 100 x 100 which on non-Retina displays will hold true, but on Retina displays under the surface the physical size will actually be 200 x 200 because it'll take into account the scaleFactor
.
Either way, the UIImageView
will scale the image accordingly.
I have an experience that it works opposite way..so scale it for retina and iphone 3G or 3GS will display it correctly.
精彩评论