UIImage 在 UIImageView 中获取 distorted/wrong 大小

UIImage gets distorted/wrong size in UIImageView

我有两个尺寸为 64 x 16 的 UIImageView 和两个图像 (@2x):

我已将 image1 放入 imageview1 并将 image2 放入 imageview2

当我 运行 应用程序时,imageview1 看起来不错,但 imageview2 看起来变形了。如何处理不同的图像尺寸?我希望 UIImageView 大小固定 (64 x 32)。

任何帮助将不胜感激

image1 with dimension 128 x 32 and image2 with dimension 80 x 32

您的 2x 图片应该 160 x 64,而不是 128 x 32。

编辑:

如果你有一个 64x16 points 的 UIImageView,那么在 2x 比例的屏幕上会产生 128 x 32 pixels,如果你有一张 80 x 32 像素的图像,如果你试图将它放在 64x16 点(128x32 像素)UIImageView

内,它会变得混乱