chancyWu chancyWu - 1 month ago 11
iOS Question

how to set the UIImageView align left or right when set the contentMode to UIViewContentModeScaleAspectFit?

I want to control the image alignment when using the

UIViewContentModeScaleAspectFit
in
UIImageView
.

enter image description here

For example, I have two
UIImageView
in one view as above.these two
UIImageView
's contentMode is
UIViewContentModeScaleAspectFit
. Now I want to set image 3 to align right and image 4 to align left, so that these two images can be together.

I try to set the contentMode to
UIViewContentModeScaleAspect|UIViewContentModeLeft
, but it make things worse.

Any suggestions are appreciated.

Answer

Finally, I find UIImageViewAligned project which can work it out.