Xcode AutoLayout, Make Margin proportional with height(Xcode AutoLayout,使边距与高度成比例)
问题描述
我很想弄清楚如何使两个对象的边距成比例.如果我在 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,使边距与高度成比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Xcode AutoLayout,使边距与高度成比例


- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- URL编码Swift iOS 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- UITextView 内容插图 2022-01-01
- GPS状态的广播接收器? 2022-01-01