简体   繁体   中英

Image cropping and image resizing with Xamarin.Ios

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM