问题描述
我有我想在屏幕的顶部部分放置一个图像。我已经设置了模式方面适合,因为我想preserve原始比例。我还设置左,顶部和右侧约束0:
I have an image that i would like to place in the top part of the screen. I've set its mode to aspect fit, because i want to preserve original ratio. I've also set left, top and right constraints to 0:
尽管顶部约束设置为0的事实,有很多的形象,这绝对不是我想要的屏幕顶部之间的间距:
Despite the fact that the top constraint is set to 0, there is a lot of empty space between the image and top of the screen which is definitely not what i want:
只有当我机顶盒制约关于-100我得到类似我想达到什么样的内容:
Only when i set top constraint to about "-100" i get something similar to what i would like to achieve:
能否请您解释一下我这样的非直观的行为,并告诉我,我应该怎么办放置在屏幕顶部的图像没有任何间隙 - 就像上面的图片
Could you please explain me such non intuitive behaviour and tell me what should i do to place the image on the top of the screen without any gaps - like on the image above.
推荐答案
一些试验的错误我想出的东西是什么,我本来想99%后。左,顶部和右侧的约束已被设置为0,宽高比约束也有被激活。在那顶规模,以填补模式。这工作得很好,除了这一事实,你算算你自己正确的图像比例。
After some trials an errors i come up with something that is 99% of what i originally wanted. Left, top and right constraint has to be set to 0, aspect ratio constraint also has to be enabled. On top of that "Scale to fill" mode. This works quite well besides that fact that you have to calculate the correct image ratio on your own.
这篇关于iOS的自动布局 - 图像和屏幕的顶部之间的间隙,尽管限制设定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!