ios - 如何使 NSConstraint 的长度根据设备大小按比例变化

标签 ios iphone swift constants ios10

我想根据设备尺寸更改上述约束的长度,因此我的文本始终与屏幕顶部成比例的距离。

enter image description here

最佳答案

您可以通过在 UI 本身中调整乘数来添加屏幕高度来实现比例顶部空间。

它会自动调整顶部空间而不做任何导出限制。

-> UIView

     -> UILabel (make hidden,for adjusting proportional top space)

         Constraints : top space - 8(default), width - 50(constant any value) , center horizantaly of parent UIView, equal height to parent UIView.
         Now modify your multipliers of proportional height to 0.2 (20% from your main view height) or 0.3(30 %).It will adjust based on screen size automatically.

     - > UILabel (Verification Code) Constraints : top space min 8 (default) & others...

enter image description here

关于ios - 如何使 NSConstraint 的长度根据设备大小按比例变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44774143/

相关文章:

ios - CoreData 获取所有一对多关系

ios - AVCaptureVideoPreviewLayer 旋转不起作用

iphone - Xcode 生成的 Core Data 托管对象,是否需要添加 dealloc 方法来释放变量?

ios - TableView 复选框不接受索引 0 的操作

ios - 用户界面 Storyboard : What's the Correct Way to Get the Active Storyboard?

iphone - 网页上显示 iPhone 应用程序下载量

ios - 当应用程序被终止(非事件)时,点击 Firebase 通知不起作用

iphone - 在 objective c iPhone 中绘制标尺

ios - UIScrollView 不滚动也没有出现在正确的位置

ios - 想要对两个不同的情况使用 UIViewController 流