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,使边距与高度成比例
基础教程推荐
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
