所以,在我的应用程序中,我有一个 UIView(它会调整大小以保持相同的纵横比,以便它始终接触屏幕的两侧)并且在该 View 中,我在其顶部有一个 UIImageView 和一个 UITextView。 视觉上(粉色矩形是 TextView ):
我想要实现的是,如果 UITextView 变高(向其中添加了更多文本),它会降低 UIImageView 的高度。 视觉上:
我应该使用什么约束或如何使用自动布局来实现?
提前致谢!
最佳答案
UITextField 约束:
Leading space, Trailing space, Top space to UIView margins constraints + Height constraint of the textfield.
UIImageView 约束:
Leading space, Trailing space, Bottom space to UIView margins constraints + Top space constraint to UITextField.
然后,当您更改 UITextField 的高度约束时,您的 UIImageView 将向下移动。
关于ios - 使用 AutoLayout 缩小 UIImageView 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30682974/