Xamarin.forms 如何更改选项卡页选项卡中文本的字体大小
我正在处理Xamarin表单,似乎我需要调整每个选项卡中文本的字体大小,因为我必须为TabbedPage包含许多选项卡 问题:如何调整选项卡的字体大小 我试图使用选项卡的属性,但没有Xamarin.forms 如何更改选项卡页选项卡中文本的字体大小,xamarin.forms,Xamarin.forms,我正在处理Xamarin表单,似乎我需要调整每个选项卡中文本的字体大小,因为我必须为TabbedPage包含许多选项卡 问题:如何调整选项卡的字体大小 我试图使用选项卡的属性,但没有 public Product() { InitializeComponent(); this.title = ?? } <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="ht
public Product()
{
InitializeComponent();
this.title = ??
}
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local ="clr-namespace:MyApp.View"
BackgroundColor="White"
Title="Product and Service"
x:Class="MayApp.View.MainMenu">
<ContentPage.ToolbarItems>
<ToolbarItem Name="MenuItem1" Order="Primary" Icon="itemIcon1" Command="{Binding Item1Command}" Priority="0" />
<ToolbarItem Name="MenuItem2" Order="Primary" Icon="itemIcon2" Priority="1" />
</ContentPage.ToolbarItems>
<local:Product>
</local:Product>
<local:Service>
</local:Service>
</TabbedPage>
公共产品()
{
初始化组件();
this.title=??
}
要为iOS更改此选项,您需要一个自定义呈现程序,其中包含迭代选项卡项的代码,并使用uitexttributes
更改其字体大小。在Xamarin没有办法做到这一点。表单本身
if (TabBar.Items != null)
{
foreach (var t in TabBar.Items)
{
var fontSize = new UITextAttributes() { Font = UIFont.SystemFontOfSize(15) };
t.SetTitleTextAttributes(fontSize, UIControlState.Normal);
}
}
我以前的工作可能是helpful@Yehor如何处理iOS和Android?您的解决方案仅适用于Droid。如果答案对您有帮助,请将标记视为回答/投票。是否需要创建继承自定义渲染器的自定义类?将哪个自定义渲染器设置为子类。对Android使用相同的方法?我相信上面已经给出了一个Android解决方案。您应该将tabderer子类化。