关于 UIImageView 的不同屏幕尺寸

Different screen sizes regarding UIImageView

如果我在我的故事板上设置了 UIImageView 并且我在我的 .m 文件上设置为图像 "test.png" 我需要根据屏幕尺寸指定要使用的图像还是我只需要创建分辨率更高的图像并将它们重命名为 "test@2x.png" 和 "test@3x.png"

UIKit 支持自动加载图像的高分辨率变体(@2x、@3x)。

引自 Apple Supporting High-Resolution Screens In Views

The UIImage class handles all of the work needed to load high-resolution images into your app. When creating new image objects, you use the same name to request both the standard and the high-resolution versions of your image.

基本上,如果您直接从代码加载图像,只需使用不带变体指示符的名称,例如:

UIImage *myImage = [UIImage imageNamed:@"test"];

如果您要在情节提要中设置图像,再次选择(建议的)名称 ("test"),如果分辨率可用,系统会自动选择正确的分辨率。