Center multiple views with varying height using au

2019-09-07 04:47发布

问题:

This answer: https://stackoverflow.com/a/25898949/1364053 is suitable for my problem to some extent. What I need is there are three views in my container view.

The middle one is a scroll view. If I pin height and width of all three views and use the ratio method as described in the above link, all works fine.

But I need the middle scrollview to grow to some extent, let's say the current height of the scroll view is 30, If the device height is increased it should grow to a max of 40 but not more than that (<= constraint).

Ok..So I tried giving two constraints to the middle view. The <= constraint has higher priorty (750) than the = constraint (250).. but when the screen size is increased.. the height stays the same.

回答1:

Sample.xib The uploaded xib might help you.