Using images on iPhone (regular and @ 2x)

So, I am creating an application that uses images for buttons. I have provided both normal images and @ 2x images, however I'm not sure which one I should use. Basically, there is no difference if I use normal.png or normal@2x.png. However, I read that using @ 2x takes up more memory, so I feel like I shouldn't do this. However, when I run my application in the iPad simulator, it looks bad when using normal-sized images, because it needs to resize them. When I use the @ 2x image, it looks fine. So, any suggestions on how I should approach this?

+4
source share
2 answers

To support retina devices, you must include images with .png and @2x.png in the application. It provides a nice user interface for your user.

Throughout the code, you do not explicitly specify the @2x suffix, since the OS will take care of this for you. For example, if you include image.png and image@2x.png in your project and access it through:

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

The OS will select the correct image for you ( .png for devices without a retina, @2x.png for retina devices). You do not need to worry about the difference in memory usage for each of them if you adhere to the general rules of memory management.

+9
source

You must:

  • Include both regular and @ 2X images in the application.
  • As soon as you finish working with the application, check it for memory (does the application run out of memory or frequent warnings about memory appear? After compression, is the application extremely large and takes too long to load to your tastes?)
  • If in memory there was a problem with deleting assets @ 2X. You must eliminate assets depending on how large the asset is and how much worse it looks when resized. For example, a full-color full-color background will not differ much when resized and may save you some memory. A small button with a lot of complex linear work will look much worse when resized, but does not take up much RAM.
+3
source

Source: https://habr.com/ru/post/1445546/


All Articles