ios - 使用 AutoLayout 缩小 UIImageView 高度

标签 ios objective-c uiimageview autolayout uitextview

所以,在我的应用程序中,我有一个 UIView(它会调整大小以保持相同的纵横比,以便它始终接触屏幕的两侧)并且在该 View 中,我在其顶部有一个 UIImageView 和一个 UITextView。 视觉上(粉色矩形是 TextView ): enter image description here

我想要实现的是,如果 UITextView 变高(向其中添加了更多文本),它会降低 UIImageView 的高度。 视觉上: enter image description here

我应该使用什么约束或如何使用自动布局来实现?

提前致谢!

最佳答案

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/

相关文章:

ios - 用户在 iOS 设备上向下滑动通知中心屏幕时意外调用 UIApplication.didBecomeActiveNotification 一次

ios - Controller 中的旋转木马在我的收藏 View 中弄乱了尺寸

ios - Core Data 数据库中的 Z_PK 列

ios - 卸载iOS应用程序时是否删除了 Realm 文件

ios - 使用 UIGestureRecognizer 旋转瓶子

ios - xcode 6, ios 8, object-C++

ios - 在位置访问权限中按下允许按钮后如何执行操作?

ios - 在 UIView 上创建一个 mask ,将所有 UIImageView subview 着色为黑白

ios - 理解 dispatch_sync

ios - setImageWith Url 完成 block swift ios