IOS 8图像缩放和自动布局 [英] IOS 8 image scaling and auto layout
问题描述
可以说我有一个的UIView
与在的UIView
,和我的顶部居中只有一个映像提供的图片资源的图像,像这样
lets say I have a UIView
with only one image centred in the top part of the UIView
, and I provided an image asset for the image like so
- 正常的iPhone 4S和更早的50×50 </ li>
- @ 2倍的iPhone 5 / 5C / 5S / 6 100×100
- @ 3倍于iPhone 150×150 6+
因此很明显,图像的宽度和高度,通过不同的设备增加,这些问题是我该如何处理汽车的布局,我应设置宽度和高度约束大于或等于还是什么?而且我怎么处理图像本身的定位是什么?而且我注意到,iPhone模拟器总是使用相同的图像不同设备的最后一件事,它是一个错误或从我这边出了问题?
So apparently the width and height of the image get increased with different devices, so the questions is how do I deal with auto layout, should I set the width and height constraints to greater than or equal or what? And also how do I deal with the positioning of the image itself? And the last thing I noticed that the IOS simulator always uses the same image for different devices, is it a bug or a problem from my end?
推荐答案
您需要了解此点与像素之间的差异。我们不是在像素点,但在设计界面生成器的看法。
You need to understand difference between points and pixels for this. We design views in interface builder not in pixels but points.
1。对于普通屏(非视网膜)分=像素。
因此,如果我们在界面生成器设置图像视图的高度和宽度50 * 50和50像素装载的50个图像,它很适合吧,如果我们通过100像素的50 * 50的ImageView加载100图像它会重新调整的形象和可能出现的一些COM pression文物。
So if we set image view's height and width to 50 * 50 in interface builder and load up image of 50 by 50 pixels, it will just fit right, if we load image of 100 by 100 pixel in a 50*50 imageview it will rescale the image and some compression artifacts may arise.
2。对于视网膜显示点= 2像素。
因此,对于一个50 * 50的图像视图,你需要加载100 * 100像素的图像。它看起来更清晰,不会出现COM pression文物。
So for a 50*50 image view you need to load up image of 100*100 pixel . It will look sharper and no compression artifacts occur.
3。对于6+点= 3像素。
因此,对于50 * 50的图像视图,你需要加载150 * 150的图像。
So for 50*50 image view you need to load up 150*150 image.
你presume的ImageView的不会重新调整到150 * 150 6+。这将是50 * 50,但是包含150 * 150像素的图像,这将导致超锋利显示
The imageview won't rescale to 150*150 in 6+ as you presume . It will be 50*50 but contain 150*150 pixel image which will result in super sharp display.
这篇关于IOS 8图像缩放和自动布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!