0

In my program I have an image which has been scaled down to a size which fits perfectly on the screen. Upon further investigation, I realized those dimensions must be doubled to provide maximum quality in iPhone Retina. I doubled those dimensions by using the original image (which was much larger) so there was no loss in quality. However, when I run my program in iPhone simulator (retina display) the image's quality has not changed whatsoever. Is there any apparent reason why Xcode does not seem to recognize that the image has been updated? Any help is appreciated.

Fitzy
  • 1,871
  • 6
  • 23
  • 40

1 Answers1

2

When you have two versions of the image (normal and @2x), use the "normal" name (without @2x) in XIB or UIImage#imageWithName:, system will automatically choose the best version for the current screen. Also check that your UIImageView size corresponds to the normal (not 2x) resolution of your image. There are several content modes (like Aspect Fit, Aspect Fill, Center, etc.) that will resize or position your image in the UIImageView.

Vlas Voloshin
  • 543
  • 1
  • 7
  • 21
  • so is it necessary to put two images (normal and @2x) to the project, when set it as the image of a button? – lu yuan Jun 04 '12 at 08:15
  • Yes, if you want to support both retina and non-retina displays (that is, if you want to support devices older than iPhone 4). – Vlas Voloshin Jun 04 '12 at 08:19
  • Is it ok to provide the high resolution image for the non-regina displays? – lu yuan Jun 04 '12 at 08:20
  • I don't have two versions of the image, what I am trying to do is, for example, taking a 200x200 image and putting it into a 100x100 frame so it will work in both normal and retina. This seems to work for alot of other images in my program, but Xcode is simply not recognizing the size change when I do this.... – Fitzy Jun 04 '12 at 08:22
  • @Fitzy what's your fit strategy? – lu yuan Jun 04 '12 at 08:24
  • You can drop the normal-resolution image, but this is not recommended. iOS will take the 2x image and resize it down to normal resolution in such case. Check the content mode of the UIImageView. It should be Aspect Fit. – Vlas Voloshin Jun 04 '12 at 08:24