Step1:CustomNavigation.xaml
Step2:CustomNavigation.xaml.cs
Step3:MainView.xaml
Step4:AndroidRenderer
Step5:Ios Renderer
Step6:Holaa!! No more Steps :D
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
<NavigationPage | |
xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
x:Class="CustomFontsNavigationPage.Views.CustomNavigationPage"> | |
</NavigationPage> |
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
public CustomNavigationPage() : base() | |
{ | |
InitializeComponent(); | |
} | |
public CustomNavigationPage(Page root) : base(root) | |
{ | |
InitializeComponent(); | |
} |
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
Title="Custom font Main Page"> |
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
[assembly: ExportRenderer(typeof(CustomNavigationPage), typeof(CustomNavigationPageRenderer))] | |
namespace CustomFontsNavigationPage.Droid.Renderers | |
{ | |
public class CustomNavigationPageRenderer : NavigationPageRenderer | |
{ | |
private Android.Support.V7.Widget.Toolbar _toolbar; | |
public override void OnViewAdded(Android.Views.View child) | |
{ | |
base.OnViewAdded(child); | |
if (child.GetType() == typeof(Android.Support.V7.Widget.Toolbar)) | |
{ | |
_toolbar = (Android.Support.V7.Widget.Toolbar)child; | |
_toolbar.ChildViewAdded += Toolbar_ChildViewAdded; | |
} | |
} | |
protected override void Dispose(bool disposing) | |
{ | |
base.Dispose(disposing); | |
if(disposing) | |
{ | |
_toolbar.ChildViewAdded -= Toolbar_ChildViewAdded; | |
} | |
} | |
private void Toolbar_ChildViewAdded(object sender, ChildViewAddedEventArgs e) | |
{ | |
var view = e.Child.GetType(); | |
if (e.Child.GetType() == typeof(Android.Widget.TextView)) | |
{ | |
var textView = (Android.Widget.TextView)e.Child; | |
var spaceFont = Typeface.CreateFromAsset(Forms.Context.ApplicationContext.Assets, "segoesc.ttf"); | |
textView.Typeface = spaceFont; | |
_toolbar.ChildViewAdded -= Toolbar_ChildViewAdded; | |
} | |
} | |
} | |
} |
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
[assembly: ExportRenderer(typeof(CustomNavigationPage), typeof(CustomNavigationPageRenderer))] | |
namespace CustomFontsNavigationPage.iOS.Renderers | |
{ | |
public class CustomNavigationPageRenderer : NavigationRenderer | |
{ | |
protected override void OnElementChanged(VisualElementChangedEventArgs e) | |
{ | |
base.OnElementChanged(e); | |
if (e.NewElement != null) | |
{ | |
var att = new UITextAttributes(); | |
att.Font = UIFont.FromName("segoesc.ttf", 20); | |
UINavigationBar.Appearance.SetTitleTextAttributes(att); | |
} | |
} | |
} | |
} |
This comment has been removed by the author.
ReplyDeletethanks
ReplyDelete