I have a seemingly simple design that I cannot express using Auto Layout constraints: in UIScrollView I need to show a centered column of text with a minimum width of 300 points and a maximum width of 500 points (saving a valid border of at least 10 points in all cases .)
The column of text is actually a UIStackView, but it does not really matter for this discussion, the view can also be easily compatible with UIImageView.
I tried to use uppercase views with different content and compression resistance, stack representation with a horizontal axis, width restrictions with constants with less or equal, etc. I want to do all this in a storyboard, sniffing during layout changes or using size classes feels like a hoax.
(Some of my experiments forced Xcode to hang by updating the storyboard: giving me a painful hint of no solution for these limitations).
And before you suggest this, I read about the intricacies of UIScrollView and Auto Layout .
This seems like an insoluble problem, which is a shame. This is a very common model, and designers like to use something with CSS (using min-width and max-width). Hope I missed something and that someone with a deeper knowledge of the automatic layout can explain the way to do this (and act as a link for others who would like to do the same.)
Update: The suggestions of Adam and Ben below are very useful for achieving this layout. But once you get a few blocks of text, the automatic iterative auto-layout solver cannot handle it (and Xcode freezes.) For more information: http://openradar.appspot.com/25173433
source share