ios - 如何使用自动布局动态更改 super View 的高度

标签 ios swift autolayout nslayoutconstraint

我在一个 View 中有两个 subview ,它们的大小是通过自动布局中的约束来管理的。

如何更改 super View 相对于 subview 高度的高度?

我刚刚创建了一个存在问题的存储库:https://github.com/Deviasoft-Official/IOS-ScrollViewAndAutoLayout

更准确地说,我的问题是如何删除该文件中的第 36 行: https://github.com/Deviasoft-Official/IOS-ScrollViewAndAutoLayout/blob/master/ScrollViewAndAutolayout/ViewController.swift

最佳答案

这里讨论这个问题。

Resize the superview automatically with auto layout .

UIScrollView auto height in Swift

我通过在 xib 中应用自动布局来实现这一点。如果您不使用 xib,请在 Visual Format 中尝试相同的逻辑。 否则,如果 xib 存在,最好在那里给出约束。

关于ios - 如何使用自动布局动态更改 super View 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34840004/

相关文章:

ios - 如何从框架中查看应用程序build设置

ios - 为什么 UITableViewCell 缩小了 contentView?

iphone - 在 UIActionSheet 中,iPhone 没有显示取消按钮?

ios - 强制用户将屏幕旋转为横向(iOS)

swift - Xcode 10 存档构建编译失败

ios - 当我使用几种不同的方式显示单元格时,是否可以在 UITableViewCell 中有不同的高度?

ios - 自动布局和 "Hide bottom bar when pushed"

iphone - Storyboard自动布局 : "trailing space to container" vs "bottom space to bottom layout"

ios - UITabBarController 添加不带选项卡栏项目的 View Controller

swift - 为什么类型未声明?