I have an ImageView which I am attempting to make Circular in Xamarin. This would be simple enough and I would have done it with Core Animation, but the images are being downloaded Asynchronously like this:
this.profileImage.InvokeOnMainThread (() => this.profileImage.SetImage (
url: new NSUrl (datum.user.profile_picture)
)
);
How would I make these images circular?
This is How I ended Up fixing my issue:
this.profileImage.InvokeOnMainThread (() => this.profileImage.SetImage (
url: new NSUrl (datum.user.profile_picture)
)
);
// Make Image Profile Image Circular
CALayer profileImageCircle = profileImage.Layer;
profileImageCircle.CornerRadius = 30;
profileImageCircle.MasksToBounds = true;
Following this - Late to the party but can be helpful
** Using OP's Code to make the application more generic as to make any image - regardless of size, circular **
this.profileImage.InvokeOnMainThread (() => this.profileImage.SetImage (
url: new NSUrl (datum.user.profile_picture)
)
);
// Make Image Profile Image Circular
CALayer profileImageCircle = profileImage.Layer;
profileImageCircle.CornerRadius = profileImageCircle.Frame.Size.Width / 2;
profileImageCircle.MasksToBounds = true;
By Adding "profileImageCircle.Frame.Size.Width / 2;" we will get the radius needed for the image we are using, so that it will always be circular - assuming it is a square image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With