我有一个带有3个UIViews的UIView作为其子视图。 我已将这些子视图的布局约束设置为固定宽高比。 即如果屏幕尺寸改变,它们的宽度将改变,但纵横比将始终相同。
现在我也使UIView的宽度(屏幕截图中显示的红色)随着屏幕尺寸的变化而变化。 但我正在努力限制这种观点的高度。 我想要的是它的高度应该根据它里面的子视图的总高度来设置。
因为如果屏幕的宽度发生变化,子视图的高度将会改变,因为我已经修正了它们的宽高比。
截至目前,我已经确定了红色超级视图的高度。 但我希望它根据其中所有子视图的总高度而变化。
这是我的viewcontroller及其预览的屏幕截图。
正如您所看到的那样,由于红色超视图的固定高度,因此剩余一些空间。
到目前为止我所添加的约束细节如下。
主红色SuperView
**分别为第1(上),第2(中),第3(下)子视图**
I have a UIView with 3 UIViews as its subviews. I have set layout constraints for these subview as fixed aspect ratio. i.e if the screen size changes their width will change but aspect ratio will always be the same.
Now i have also made width of the UIView (the red one as shown in screen shot) changing as the screen size changes. But i am struggling to make constraint for height of this view. what i want is its height should be set according to the total height of the subviews inside it.
since the height of the subviews will change if the width of the screen changes, because i have made their aspect ratios fixed.
As of right now i have made height of the Red superview fixed. but i want it to be variable according the total height of all the subviews inside it.
Here is the screen shot of my viewcontroller and its preview.
As you can see there is some space remaining because of the fixed height of red super view.
Details of the constraints i have added so far are as bellow.
Main Red SuperView
**1st (Top), 2nd (Middle), 3rd (Bottom) Subviews respectively **
请发表评论