Iphone移动应用程序中的圆形图像范围(Xamarin.Ios / C#)

问题描述 投票:1回答:2

我似乎无法找到如何获得圆形图像。无论是从照片库中选择的照片,还是喜欢它适合在屏幕上显示的范围,并且图片在应用程序上呈圆形,而不是默认的矩形或方形照片。 instagram twitter facebook和linkedIN等都这样做。有人能指出我正确的方向,可能会看一个插件,一个我可以调用的方法的名称,或一个链接或代码,这将帮助我实现这一目标

c# ios visual-studio xamarin xamarin.ios
2个回答
0
投票

您可以尝试使用以下代码:

  UIImageView imageView = new UIImageView(new CGRect( 10,10,200,200 ));// Make sure the width and height are equal
  imageView.Image =UIImage.FromBundle(" xxx.png ");
  imageView.Layer.MasksToBounds = true; //It is important
  imageView.Layer.CornerRadius = 100;  //Set the value to half of the width(height)
  View.AddSubview(imageView);

0
投票

您可以参考以下链接来实现圆形图像/圆形图像功能:

https://github.com/jamesmontemagno/ImageCirclePlugin

我在我的Xamarin应用程序中使用了它,它没有任何问题。

希望这对你有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.