ios - Autolayout aspect ratio based on `intrinsicContentSize` (not constant) -


is possible apply such auto layout constraints aspect ratio calculated on fly based on intrinsiccontentsize? in documentation i've found constrains fixed ratio value.

actual , height intrinsiccontentsize not important in use case, want preserve height , width ratio of view changes dynamically.

should provide own implementation of constraint? or there better way?

you can find answer on how set ratio-based constraints here. need constrain width , height together, maintaining given aspect ratio (in case 4/3).

we can debate whether it's thing views know information or whether should parents set kind of constraints. prefer parents set constraints, if view doesn't make sense without constraint or these views need constraint, can safely let these views manage own width/height ratio.

finally, intrinsiccontentsize tells auto layout size of view when view alone:

returns natural size receiving view, considering properties of view itself.

i don't know view represents, documentation says, can return cgsizemake(uiviewnointrinsicmetric, uiviewnointrinsicmetric):

if custom view has no intrinsic size given dimension, can return uiviewnointrinsicmetric dimension.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -