gpt4 book ai didi

xcode - 仅在界面构建器中使用 AutoLayout 在 UIScrollView 中居中 UIView

转载 作者:行者123 更新时间:2023-12-01 09:47:42 24 4
gpt4 key购买 nike

我试图仅使用界面生成器将 View 置于 UIScrollView 内。使用标签似乎效果很好。

enter image description here enter image description here

但是当我尝试对 UIView 执行相同操作时,我遇到了约束冲突。

enter image description here enter image description here enter image description here

冲突是有道理的,但如果我删除宽度/高度约束,UIView 会扩展到整个 SuperView,如果我删除顶部/前导/尾部/底部约束,UIView 会正确地居中,但我得到一个模棱两可的宽度/高度警告。

enter image description here

我的问题是,如何让 UIView 与 UILabel 一样居中?

最佳答案

供将来引用:

enter image description here enter image description here

但关键是设置不同的 ContentHugging 优先级,以帮助 AutoLayout 解决冲突:

enter image description here

关于xcode - 仅在界面构建器中使用 AutoLayout 在 UIScrollView 中居中 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38512222/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com