简体   繁体   中英

@1x size of image assets in iOS

When adding images to an iOS project, what size should the 1x image be?

For example:

If I have 2 UIImageView with the same image with a size of 50x50pt and 30x30pt. Can I make one image asset for the both (and which size should this be) or should I make 2 assets ie. image30x30.png and image50x50.png?

This of course extends to images that have a dynamic size (for example 50% of the screen width), which size should they be?

You have 2 options:

  1. Use 1 image and just resize UIImageView
  2. Yes, you should use 2 different assets if 1. won't work for you

您必须为UIImageView使用2个不同的图像资源。

When you want to resize an image you must remember 2 things:

  1. you must maintain the h/w ratio of that image.
  2. you must resize to smaller from it's original size otherwise the resized image will look blur .

So, according to your (50x50pt and 30x30pt)images size the best option is to maintain 1 image and it size must be 50x50pt

i) resize this image smaller into 30x30pt

ii) you should not consider image ratio as both image maintain same ratio.(50/50=1 and 30/30 =1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM