使用AutoLayout(故事板)自动将UIView的高度调整为其子视图 [英] Automatically Adjust UIView's Height to It's Subview using AutoLayout (Storyboard)
问题描述
我正在使用StoryBoards和Autolayout.
下面是层次结构:
-超级视图-UIView(ContentView)--- UITextField--- UITextField--- UITextField--- UITextField
UIView(ContentView)的位置限制为SuperView的左,上,右,偏移量为20;
UIView(ContentView)的底部不受任何限制.
我想根据其中的textField调整contentView的高度.有什么想法可以使用AutoLayout实现吗?
我在Autolayout方面是个新手.用于执行代码中的所有UI.
有什么想法吗?
谢谢!
对不起,找到答案了,我只是限制所有子视图的高度,然后将底部子视图的最底部限制到UIView/ContentView >
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
这篇关于使用AutoLayout(故事板)自动将UIView的高度调整为其子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!