[英]How setting width and height constraints of UI controls in iOS works when we use different size and types of screen?
I am learning Auto-layout in iOS, how setting margin or setting width and height of control will scale according to different size of iPhone and iPad sizes. 我正在学习iOS中的自动版式,如何设置边距或设置控件的宽度和高度如何根据iPhone和iPad尺寸的不同而缩放。
For example, if I set image of 200 by 200 in iPhone, will it not look very small as compared to iPad, even iPhone 5S is much smaller than iPhone 6S Plus. 例如,如果我在iPhone中将图像设置为200 x 200,与iPad相比看起来会不会很小,即使iPhone 5S也比iPhone 6S Plus小得多。
I am missing something important related to Auto-layout? 我缺少与自动布局相关的重要信息吗?
We always use 'size class' to adapt iPhone and iPad. 我们始终使用“尺寸等级”来适应iPhone和iPad。 So if you want to have a image of 200 by 200 in iPhone just setting in wC-hA size, then change size to wR-hR to set 300*300 for iPad. 因此,如果您想在iPhone中以200 x 200的比例仅设置wC-hA尺寸,则将尺寸更改为wR-hR即可为iPad设置300 * 300。
You maybe not want to set a absolute width to image, the aspect ratio constraint is a good way to set relative width: 您可能不想为图像设置绝对宽度,长宽比约束是设置相对宽度的好方法:
It will set the button's width equal to a quarter of superview's width. 它将设置按钮的宽度等于超级视图宽度的四分之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.