[assembly: ExportRenderer(typeof(AppShell), typeof(MyShellRenderer))]
namespace App30.Droid
{
public class MyShellRenderer : ShellRenderer
{
public MyShellRenderer(Context context) : base(context)
{
}
protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(ShellItem shellItem)
{
return new CustomBottomNavAppearance();
}
}
public class CustomBottomNavAppearance : IShellBottomNavViewAppearanceTracker
{
public void Dispose()
{
}
public void ResetAppearance(BottomNavigationView bottomView)
{
}
public void SetAppearance(BottomNavigationView bottomView, ShellAppearance appearance)
{
IMenu menu = bottomView.Menu;
for (int i = 0; i < bottomView.Menu.Size(); i++)
{
IMenuItem menuItem = menu.GetItem(i);
var title = menuItem.TitleFormatted;
SpannableStringBuilder sb = new SpannableStringBuilder(title);
int a = sb.Length();
//here I set fontsize 20
sb.SetSpan(new AbsoluteSizeSpan(20,true), 0, a, SpanTypes.ExclusiveExclusive);
menuItem.SetTitle(sb);
}
}
}
}
1条答案
按热度按时间ylamdve61#
要更改NavigationBar中的标题字体,请阅读此文档,在每个contentPage中自定义
Shell.TitleView
:字符串
要更改选项卡栏标题字体,您需要一个自定义渲染器:
型
结果如下:
的数据
一个sample project已经上传到这里,你可以检查它。