Forum Xamarin.iOS

UIImageView AspectFit mode with AutoLayout

LeiKanLeiKan CNMember
edited October 2015 in Xamarin.iOS

I use a container view for my UILabels and UImageViews.
1.constraint the first subview's top to container view's top.
2.constraint the last subview's bottom to container view's bottom.
3.constraint the height between subviews;
4.constraint UILabel and UIImageView's leading to container view's leading.
5.constraint UILabel and UIImageView width.

then Set the UIImageView contentmode = AspectFit.

With above constraints, the label and imageview have flexible height with their's content.
But the UIImageView is bigger than real image (blank area in the picture), how to use autolayout constraint UIImageView to the image's real size?
And the image is dynamic load, so I cannot set the UIImageView's frame.
Thanks in advance.

Best Answer


  • RomainLouisRomainLouis NZMember

    I'm having the same problem Lei.

    Have you found a solution ?

Sign In or Register to comment.