简体   繁体   English

要在图片集中上传哪3张尺寸/分辨率的图片以支持所有设备?

[英]Which 3 size/resolution images to upload in image set to support all devices?

Image assets are now preferred over resources in IOS, which supports to upload only 3 versions of the image. 与IOS中的资源相比,现在优先使用图像资产,该资源仅支持上传3个版本的图像。 1x, 2x & 3x. 1x,2x和3x。

But there are number of device resolutions to support on iPhones 但是iPhone上支持多种设备分辨率

640x1136 - 5 series 640x1136-5系列
750x1334 - 6, 6s, 7, 8 750x1334-6,6s,7,8
1242x2208 - (6, 6s, 7, 8) plus 1242x2208-(6,6s,7,8)加
1125x2436 - X, XS 1125x2436-X,XS
828x1792 - XR 828x1792-XR
1242x2688 - XS Max 1242x2688-XS最大

I can understand what 1x, 2x & 3x resolutions are, eg. 我可以理解例如1x,2x和3x的分辨率。 320px(1x), 640px(2x) & 960(3x). 320px(1x),640px(2x)和960(3x)。

But I can not understand which 3 image sizes to upload to support all devices, so that complete image appear full screen on all devices? 但是我不知道要上传哪种3种图像尺寸来支持所有设备,以便完整的图像在所有设备上全屏显示?

The resolutions are 1x, 2x and 3x. 分辨率为1x,2x和3x。 In most cases you should scale sizes of images so that for instance 1x is 100x100 , 2x is 200x200 and 3x is 300x300 . 在大多数情况下,您应该缩放图像的大小,例如1x为100x100200x200300x300

This has nothing to do with resolution but rather the DPI scale. 这与分辨率无关,而是与DPI比例无关。 It is a value you get from UIScreen.main.scale . 这是您从UIScreen.main.scale获得的值。 What this is is the scale between your coordinate system and scree pixel coordinate system. 这是您的坐标系和scree像素坐标系之间的比例。 For instance if you take a 2x device with resolution of 750x1334 and print out frame you would get 375x667 by checking UIApplication.shared.keyWindow!.frame . 例如,如果您使用分辨率为750x1334的2x设备并打印出帧,则可以通过检查UIApplication.shared.keyWindow!.frame 375x667获得375x667

That means that if you place an image view with frame size 100x100 on a 2x device it will take 200x200 pixels. 这意味着,如果将帧尺寸为100x100的图像视图放置在2x设备上,则将需要200x200像素。 For 3x it will take 300x300 pixels. 对于3倍,它将需要300x300像素。 So that is why the 2x and 3x images should be larger. 因此,这就是2x和3x图像应该更大的原因。

The problem occurs if you want to scale image directly depending on screen size. 如果您要根据屏幕尺寸直接缩放图像,则会出现问题。 Assume the following: 假设以下内容:

let imageWidth: CGFloat = 44.0/375.0*view.frame.size.width

If this is used for image size then your image will proportionally resize depending on your screen size. 如果将此用于图像尺寸,则图像将根据屏幕尺寸按比例调整大小。 And doing this you would need a better system for icons than having 3 versions of it. 这样做,您将需要一个比3个版本更好的图标系统。 You could put them into assets and have 3 images per screen resolution. 您可以将它们放入资产中,每个屏幕分辨率具有3张图像。

But in most cases it is better to keep the image size and increase the whitespace around it. 但是在大多数情况下,最好保留图像大小并增加其周围的空白。 So assume a screen with width of 375 would have an image of width 100 in the middle. 因此,假设一个宽度为375的屏幕中间的图像宽度为100。 It would produce 137,5 whitespace on each of the sides. 它将在每侧产生137,5空格。 Now seeing the same scene on device with width of 414 would produce 157 whitespace on which of the sides. 现在在宽度为414的设备上看到同一场景将在侧面的哪一侧产生157个空白。 This is usually acceptable. 这通常是可以接受的。

If you really need to scale images you should also consider scaling fonts. 如果确实需要缩放图像,则还应考虑缩放字体。 If one of your icons increases in size by 10% then most likely a text next to it should have increased font size by 10%. 如果您的一个图标的大小增加了10%,则其旁边的文本很可能应该将字体大小增加了10%。 This may later greatly complicate things due to rounding of font sizes to integer value. 由于字体大小四舍五入为整数值,这可能会使事情变得更加复杂。 So I suggest you avoid this. 因此,我建议您避免这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS 背景图片分辨率:如何支持所有 iOS 设备 - iOS background image resolution: How to support all iOS devices 如何在所有iPhone设备的UIView中设置完整大小的图像背景? - How to set full size image background in UIView for All iPhone Devices? 我应该如何设计图像大小以支持所有 iOS 设备 Retina Display - How should I design images size to support all iOS Devices Retina Display 我应该如何获得所有设备的分辨率大小图标 - How I should get resolution size icons for all devices 支持所有iPhone设备所需的图像尺寸 - Image sizes required to support all iPhone devices 是否所有支持BLE 4.0的设备都可以在支持BLE 4.0的iOS设备上连接? - Are all the devices which support BLE 4.0 can be connected in my iOS devices which support BLE 4.0? 上传所有移动设备时如何调整图像大小? - How to resize image when upload for all mobile devices? 在移动设备上加载和显示高分辨率图像 - Loading and showing high resolution images on mobile devices 如何在不同设备上使用不同分辨率的图像? - how to use images on different devices on different resolution? 如何为所有Apple设备调整图像资产的大小? (不启动图像) - How to resize image assets for all Apple devices? (not launch images)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM