本文介绍了在iPhone中使用图像(普通和@ 2x)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在构建一个使用按钮图像的应用程序。我提供了普通图像和@ 2x图像,但是我不能确定应该使用哪一个。如果我使用normal.png或[email protected],基本上没有差别。但是我已经读过使用@ 2x需要更多内存,所以我觉得我不应该这样做。但是,当我在iPad模拟器中启动我的应用程序时,使用正常大小的图像看起来很糟糕,因为它需要调整它们的大小。当我使用@ 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?

推荐答案

你应该包含 .png 和 @ 2x.png 在您的应用程序中支持视网膜设备。这为您的用户提供了良好的用户体验。

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.

在整个代码中,您没有明确指定 @ 2x 后缀,因为操作系统将为您处理。例如,如果在项目中包含 image.png [email protected] ,则可通过以下方式访问它:

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"];

操作系统会为您选择正确的图像( .png 用于非视网膜设备, @ 2x.png 用于视网膜设备)。只要遵循一般的内存管理准则,您就不必担心每个内存使用的差异。

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.

这篇关于在iPhone中使用图像(普通和@ 2x)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 10:40