使UILabels / UITextFields在所有手机上的比例看起来相同

时间:2015-06-14 18:44:49

标签: ios swift autolayout

使用自动布局,在所有iPhone尺寸上制作此类内容的最佳方法是什么?

为所有单个组件添加约束导致其中一个UITextField每次都比其他组件大,我不确定如何使它们看起来大小相同,并且按比例适合所有iPhone

1 个答案:

答案 0 :(得分:1)

你有一个约束可以建立两个UIView之间的关系。

如果您从小时拖动到分钟,则可以选择“宽度”。确保常数值为1.然后您可以从小时到秒进行相同操作。

你可以also do it by code

constraint = [NSLayoutConstraint constraintWithItem:myLabel
                                          attribute:NSLayoutAttributeWidth
                                          relatedBy:NSLayoutRelationEqual
                                             toItem:otherLabel
                                          attribute:NSLayoutAttributeWidth
                                         multiplier:1.0f
                                           constant:0];
相关问题