简体   繁体   English

iOS UIImageView比例尺

[英]iOS UIImageView scale

I need to make a table of different images which has to fit exactly to a iPad Mini 2. 我需要制作一张必须完全适合iPad Mini 2的不同图像的表格。

So I have a picture with height = 60 and width = 621. If I put these sizes into the UIImageView , the picture fits nearly the whole screen of my iPad. 因此,我有一张高度= 60且宽度= 621的图片。如果将这些尺寸放入UIImageView ,则该图片几乎适合iPad的整个屏幕。

Maybe someone can tell me why this happens, as I am very new to programming with Xcode. 也许有人可以告诉我为什么会这样,因为我对使用Xcode进行编程非常陌生。

The problem is the photo is either not constrained to a scaled size (ex 30x310 to get a 2x downscale) or it is not in a stack, in the table. 问题在于照片不是被限制为缩放后的尺寸(例如30x310以获得2倍的缩小比例),或者它不在表中的堆栈中。 Try putting the images in a stack and constrain the stack. 尝试将图像放在堆栈中并限制堆栈。 Let me know if that helps! 让我知道是否有帮助!

An UIImageView holds an image. UIImageView保存一个图像。

If it stretches to fill the entire screen, it is likely that the size of your UIImageView is quite large. 如果它拉伸以填满整个屏幕,则UIImageView的大小可能会很大。 By default, the image will stretch and fill the space of your UIImageView. 默认情况下,图像将拉伸并填充UIImageView的空间。

If you want the image to stay in ratio, and stretch to the UIImageView: 如果要使图像保持比例,并拉伸到UIImageView:

imageView.contentMode = UIViewContentModeScaleAspectFit;

If you want the image to stay exactly the way it is: 如果您希望图像保持原样:

imageView.contentMode = UIViewContentModeCenter;

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

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