Created
June 28, 2017 03:04
-
-
Save Char0394/9838f3b2a8dac2a06e4438b10f7e2fcb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 System; | |
| using Android.Graphics; | |
| using FontSample.Droid; | |
| using Xamarin.Forms; | |
| using Xamarin.Forms.Platform.Android; | |
| [assembly: ExportRenderer(typeof(Label), typeof(CustomLabelRenderer))] | |
| namespace FontSample.Droid | |
| { | |
| public class CustomLabelRenderer: LabelRenderer | |
| { | |
| protected override void OnElementChanged(ElementChangedEventArgs<Label> e) | |
| { | |
| base.OnElementChanged(e); | |
| if (Control == null) | |
| return; | |
| if (!String.IsNullOrEmpty(Element.FontFamily)) | |
| Control.Typeface = Typeface.CreateFromAsset(Forms.Context.Assets, Element.FontFamily + ".ttf"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment