iPhone 图像分辨率
我正在创建一个在选择器视图中包含图像的应用程序,但我注意到这些图像出现像素化。目前,我将分辨率设置为 72 像素/英寸。我已将其增加到 300 像素/英寸,但没有注意到变化。有人遇到过这个问题吗?
I am creating an app that has images in a picker view, but I have noticed that these images appear pixelated. Currently, I have the resolution set at 72 pixels/inch. I have increased it to 300 pixels/inch, but have not noticed a change. Has anyone run into the issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您在 Photoshop 中创建这些图像,则更改 DPI 不会更改图像文件。 4x4 图像将有 16 个像素。当您更改 DPI 时,它只会更改显示屏上这些像素的大小。对于视网膜显示屏,您需要创建两倍大小的图像(例如 8x8)。
If you are creating these images in Photoshop, changing the DPI won't change the image file. A 4x4 image will have 16 pixels. When you change the DPI, it simply changes how large those pixels are on your display. In the case of the retina display, You need to create an image that is double the size (e.g. 8x8).
您需要提供与“@2x”文件相同的文件,且大小加倍。例如,如果您有:
那么您还需要:
在调用资源时,您可以使用相同的方式,忽略文件名中的
@2x
部分。 IOS 会做正确的事。在高密度设备上,它将选择较大的文件,否则它将选择较小的文件。YOu need to provide the same file as a "@2x" file with double the size. For example, if you have:
Then you also need:
When calling the resource, you can use the same way and ignore the
@2x
part of the filename. IOS will do the right thing. On high density devices, it will choose the bigger file, otherwise it will choose the smaller one.您不需要 png,但无论有没有它都可以。该代码适用于所有操作系统。如果是视网膜显示器,就会使用大图像,否则不要尝试。
You dont need the png, but it works with or without it. This code works on all OS's. If it is a retina display, it will use the big image, otherwise not try it.