OGeek|极客世界-中国程序员成长平台

标题: ios - 自动布局 : constraint that involves multiple items [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 08:46
标题: ios - 自动布局 : constraint that involves multiple items

例如,我希望将某个文本字段放置在导航栏下方,距离等于 super View 总高度的四分之一。这涉及三个项目:文本字段、顶部布局指南和 super View 。如何在 Interface Builder 中或通过编程创建这样的约束?



Best Answer-推荐答案


不可能只使用一个约束。相反,您需要在文本字段上方创建一个额外的 UIView。然后你可以设置以下约束:

  1. 4 * extraView.height = containerView.height
  2. extraView.top = topLayoutGuide
  3. extraView.bottom = textField.top

关于ios - 自动布局 : constraint that involves multiple items,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31163608/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4