I have been trying to set font size on Xamarin forms TabbedPage for the titles of pages on navigation bar for iOS.
I have tried to use TabbedView instead, however since I have quite few tabs.. and quite lot of data the application was slowing down and freezing. Plus I had to use content view instead of content pages.
I have tried custom renderer, I have seen no mistake in the output, I tried to debug the code it went through however no changes were applied and title remained exactly the same.
using tab;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(ExtendedTabbedPage), typeof(ExtendedTabbedPageRenderer))]
namespace tab
{
public class ExtendedTabbedPageRenderer : TabbedRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (TabBar != null)
{
ApplyTabTitleStyle();
}
}
private void ApplyTabTitleStyle()
{
foreach (var item in TabBar.Items)
{
item.SetTitleTextAttributes(new UITextAttributes
{
Font = UIFont.SystemFontOfSize(20)
}, UIControlState.Normal);
}
}
}
}
using System;
using Xamarin.Forms;
namespace tab
{
public class ExtendedTabbedPage : TabbedPage
{
public ExtendedTabbedPage()
{
}
}
}
I also tried this approach https://xamgirl.com/extending-tabbedpage-in-xamarin-forms/