我很想弄清楚如何使两个对象的边距成比例.如果我在 Xcode 上选择纵横比,它会给我调整对象比例屏幕高度的选项.那不是我的情况.我希望按钮和屏幕底部之间的边距与屏幕高度成正比.我希望它使用 Xcode无代码"来完成.
I am having a big time figuring out how to make the margin of two objects proportional. If i choose aspect ratio on Xcode it gives me the option for adjust the height of my object proportional screen height. and thats not my case. I want the margin between a button and screen bottom to be proportional to screen height. And i want it to be done using Xcode "No Code".
非常感谢您的支持.
谢谢
使用 NSLayoutConstraint 的 multiplier 属性!
Use the multiplier property of NSLayoutConstraint !
首先,使用您希望的乘数设置从您的视图到其父视图的等高约束.您可以使用 Ctrl + 从您的视图拖动到超级视图.
First, set the equal height constraint from your view to its superview with the multiplier you wish. You can use Ctrl + drag from your view to the superview.
然后将另一个约束设置为从视图顶部到父视图的 0,以及从视图到父视图的等宽约束,乘数为 1.
Then set another constraint at 0 from the top of your view to the superview and a equal width constrain with a multiplier to 1 from your view to the superview.
完成!
这篇关于Xcode AutoLayout,使边距与高度成比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!