2

My code:

self.commentTextViewBorder.image = [[UIImage imageNamed:@"border_comment_field"]
resizableImageWithCapInsets:UIEdgeInsetsMake(11, 11, 11, 11)];

I found it did not user @2x image file to make resiable. Is it any problem?

ZhouQi
  • 531
  • 1
  • 6
  • 16
  • Just put one condition regarding the retina display and accordingly use the @2x image for making the resized image as I know you have to do it in coding :) – The iOSDev Jan 02 '13 at 07:28
  • 1
    if device has non-ratina display use simple image like above shown in post and if it is ratina use `@"border_comment_field@2x"` instead of `@"border_comment_field"`. That's it. For determined which display device have, there is lots of posts on SO just try to search with `how to find ratina display device through coding` – The iOSDev Jan 02 '13 at 07:43
  • @Wolvorin do you means I just make a 2x image file in resource and do not need modify code, ios can make things do right? – ZhouQi Jan 02 '13 at 07:45
  • just try [this](http://stackoverflow.com/a/4641481/1132951) out – The iOSDev Jan 02 '13 at 07:45
  • 3
    @ZhouQi He doesn't say that, but it's true anyway. You don't need to change the code, `UIImage` automagically knows which image file to choose. If the app is run on a retina device, then it will choose the `@2x` image. –  Jan 02 '13 at 07:46

1 Answers1

6

Put your image_name.png & image_name@2x.png at your main bundle folder, and just use

[UIImage imageNamed:@"image_name.png"];

is fine. The correct one will be used automatically depend on the devices w/ or w/o retina display.

Kjuly
  • 34,476
  • 22
  • 104
  • 118
  • yes, you're right, but use @2x file UIEdgeInsetsMake(11, 11, 11, 11) should be UIEdgeInsetsMake(5, 5, 5, 5) – ZhouQi Jan 04 '13 at 01:20