I need to implement image compressing and maintaining the aspect ratio with Xamarin.iOS. Right now I am using below code to show image from url.
uImage.SetImage(new NSUrl(imageUrl));
Above code is showing image from url. But images which are displayed are stretched without maintaining aspect ratio.
I need some code to maintain aspect ratio.
Set ContentMode
of your UIImageView
to
UIViewContentMode.ScaleAspectFill
Scales the contents to fill the new bounaries of the view, while preserving the aspect ratio.UIViewContentMode.ScaleAspectFit
Scales the contents so that everything is visible, while preserving the aspect ratio.See visual examples at: https://developer.xamarin.com/api/type/UIKit.UIViewContentMode/