Created
November 10, 2017 21:24
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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