是一个使用自动版式(故事板)子视图自动调整的UIView的高度,以它 [英] Automatically Adjust UIView's Height to It's Subview using AutoLayout (Storyboard)
问题描述
我是用故事板和自动布局。
下面是层次结构:
- 上海华
- UIView的(内容查看)
---的UITextField
---的UITextField
---的UITextField
---的UITextField
UIView的(内容查看)的约束到左,上,与偏移20的SuperView的权利;
UIView的(内容查看)的底部,不拘泥于任何东西。
我想内容查看的身高调整基础上,有多少文本框。任何想法我怎么能做到这一点使用自动版式?
我在自动布局很新。用来做在code所有UI。
有什么想法?
感谢您!!
我傻,找到了答案,我只是限制所有的子视图的高度,然后约束底部子视图UIView的/内容查看最底p>
I am using StoryBoards and Autolayout.
Below is the hierarchy:
- Superview
-- UIView (ContentView)
--- UITextField
--- UITextField
--- UITextField
--- UITextField
The UIView(ContentView)'s is constrained to Left, Top, Right of the SuperView with the offset of 20;
The Bottom of UIView(ContentView) is not constrained to anything.
I would like the contentView's height adjusted based on how many textField in it. Any thoughts how I could achieve this using AutoLayout?
I am very new in Autolayout. Used to do all UI in code.
Any thoughts?
Thank you!!
Silly me, found the answer, I simply restrict the height of all the subviews and then constraint the most bottom of the bottom subview to the UIView/ContentView
这篇关于是一个使用自动版式(故事板)子视图自动调整的UIView的高度,以它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!