Problem
In UI I have some view which content is stretchable but should conserve some aspect ratio. This aspect ratio changes during run-time and views layout should be updated when some property describing aspect ratio changes.
I've exposed NSLayoutConstraint
, but its property used for aspect ratio: multiplier
is read only. What is more funny similar property constant
can be changed.
Possible solutions
- I could just use constraint which fixes width or height and calculate it based on expected ratio, but this requires extra boiler plate code which will react on geometry/layout changes and I prefer to avoid this.
- I could experiment with
intrisicContentSize
andsizeThatFits:
but I'm not sure how this should be used withNSLayoutConstraint