Skip to content

Instantly share code, notes, and snippets.

@juucustodio
Created November 10, 2017 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juucustodio/b9fb75e1cd7a61e3b5bac9de927abec8 to your computer and use it in GitHub Desktop.
Save juucustodio/b9fb75e1cd7a61e3b5bac9de927abec8 to your computer and use it in GitHub Desktop.
Example of BadgeView with circle box using custom renderer - http://julianocustodio.com/badgeview
using Xamarin.Forms;
using BadgeView.iOS;
using BadgeView;
using Xamarin.Forms.Platform.iOS;
using System.ComponentModel;
[assembly: ExportRenderer(typeof(CircleBox), typeof(CircleBoxRenderer))]
namespace BadgeView.iOS
{
public class CircleBoxRenderer : BoxRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e)
{
base.OnElementChanged(e);
if (Element != null)
{
Layer.MasksToBounds = true;
UpdateCornerRadius(Element as CircleBox);
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == CircleBox.CornerRadiusProperty.PropertyName)
{
UpdateCornerRadius(Element as CircleBox);
}
}
void UpdateCornerRadius(CircleBox box)
{
Layer.CornerRadius = (float)box.CornerRadius;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment