Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using images in iPhone (normal and @2x)

So I'm building an app that uses images for buttons. I provided both normal images and @2x images, however I'm not totaly sure which one I should use. There is basicly no diffrence if I use normal.png or [email protected]. However I've read that using @2x takes more memory, so I feel like I shouldn't do it. However, when I start my app in the iPad simulator, it looks bad when using normal size images, because it needs to resize them. When I use the @2x image, it looks normal. So any suggestions on how I should approach this?

like image 592
gabrjan Avatar asked Dec 16 '22 17:12

gabrjan


2 Answers

You should include images both with .png and @2x.png within your application to support retina devices. This provides a nice user experience for your user.

Throughout your code, you do not explicitly specify the @2x suffix, as the OS will take care of that for you. For example, if you include image.png and [email protected] in your project, and access it via:

UIImage* image = [UIImage imageNamed:@"image"];

The OS will select the correct image for you (.png for non retina devices, @2x.png for retina devices). You don't need to worry about the memory usage difference for each one, as long as you follow general memory management guidelines.

like image 168
WDUK Avatar answered Dec 23 '22 09:12

WDUK


You should:

  • Include both regular and @2X images in your app.
  • Once you're finished with the app check it's memory footprint (is the app running out of memory or getting frequent memory warnings? Once compressed is the app exceedingly large and takes too long to download for your tastes?)
  • If memory is an issue start removing the @2X assets. You should eliminate the assets based on how large the asset is and how much worse it looks when resized. For example, a full-screen solid color background is not going to look much different when resized and might save you some memory. A small button with lots of intricate line work is going to look distinctly worse when resized but doesn't take a lot of RAM.
like image 40
Mattia Avatar answered Dec 23 '22 08:12

Mattia