如何更改.NET Maui iOS AppShell TabBar的字体大小和图标大小?

huangapple go评论88阅读模式
英文:

How to change the FontSize and icons size of .net Maui iOS AppShell TabBar?

问题

我有这个AppShell:

<Shell.Resources>
    <Style x:Key="BaseStyle" TargetType="Element">
        <Setter Property="Shell.BackgroundColor" Value="{DynamicResource YouviRed}" />
        <Setter Property="Shell.ForegroundColor" Value="White" />
        <Setter Property="Shell.TitleColor" Value="White" />
        <Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
        <Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
        <Setter Property="Shell.NavBarIsVisible" Value="False" />
    </Style>
</Shell.Resources>
<TabBar>
    <ShellContent Title="{ext:Translate Dashboard}" Style="{StaticResource BaseStyle}" Icon="dashboard.png" ContentTemplate="{DataTemplate navi:CustomNavigationPage}" Route="Dashboard">
        <dash:DashboardView/>
    </ShellContent>
    <ShellContent Title="{ext:Translate Rooms}" Style="{StaticResource BaseStyle}" Icon="rooms.png" ContentTemplate="{DataTemplate navi:CustomNavigationPage}" Route="Rooms">
        <rooms:RoomsView/>
    </ShellContent>
    <ShellContent Title="{ext:Translate Settings}" Style="{StaticResource BaseStyle}" Icon="settings.png" ContentTemplate="{DataTemplate navi:CustomNavigationPage}" Route="Settings">
        <sett:SettingsView />
    </ShellContent>
</TabBar>

iOS TabBar的标题字体太小,图标太大,我不知道如何更改这个。我需要一个特定的处理程序吗,还是有其他更好的方法?非常感谢任何帮助,提前致谢。

英文:

I have this AppShell:

    &lt;Shell.Resources&gt;
    &lt;Style x:Key=&quot;BaseStyle&quot;
           TargetType=&quot;Element&quot;&gt;
        &lt;Setter Property=&quot;Shell.BackgroundColor&quot;
                Value=&quot;{DynamicResource YouviRed}&quot; /&gt;
        &lt;Setter Property=&quot;Shell.ForegroundColor&quot;
                Value=&quot;White&quot; /&gt;
        &lt;Setter Property=&quot;Shell.TitleColor&quot;
                Value=&quot;White&quot; /&gt;
        &lt;Setter Property=&quot;Shell.DisabledColor&quot;
                Value=&quot;#B4FFFFFF&quot; /&gt;
        &lt;Setter Property=&quot;Shell.UnselectedColor&quot;
                Value=&quot;#95FFFFFF&quot; /&gt;
        &lt;Setter Property=&quot;Shell.NavBarIsVisible&quot; 
                Value=&quot;False&quot; /&gt;
    &lt;/Style&gt;
&lt;/Shell.Resources&gt;
&lt;TabBar&gt;
    &lt;ShellContent Title=&quot;{ext:Translate Dashboard}&quot; 
                  Style=&quot;{StaticResource BaseStyle}&quot;
                  Icon=&quot;dashboard.png&quot; 
                  ContentTemplate=&quot;{DataTemplate navi:CustomNavigationPage}&quot; 
                  Route=&quot;Dashboard&quot;  &gt;
        &lt;dash:DashboardView/&gt;
    &lt;/ShellContent&gt;
    &lt;ShellContent Title=&quot;{ext:Translate Rooms}&quot; 
                  Style=&quot;{StaticResource BaseStyle}&quot;
                  Icon=&quot;rooms.png&quot; 
                  ContentTemplate=&quot;{DataTemplate navi:CustomNavigationPage}&quot; 
                  Route=&quot;Rooms&quot; &gt;
        &lt;rooms:RoomsView/&gt;
    &lt;/ShellContent&gt;
    &lt;ShellContent  Title=&quot;{ext:Translate Settings}&quot;
                   Style=&quot;{StaticResource BaseStyle}&quot;
                   Icon=&quot;settings.png&quot; 
                   ContentTemplate=&quot;{DataTemplate navi:CustomNavigationPage}&quot; 
                   Route=&quot;Settings&quot;  &gt;
        &lt;sett:SettingsView /&gt;
    &lt;/ShellContent&gt;
&lt;/TabBar&gt;

The Titles fontSize of the iOS TabBar are to small and the icons are to big, I don't know how to change this. Did I need an specific Handler for this or did anyone knows an better way ? I would be very grateful for any help, thanks in advance.
如何更改.NET Maui iOS AppShell TabBar的字体大小和图标大小?

答案1

得分: 1

Set the BaseSize of svg file works for me.

You could add the line in csproj file:

<MauiImage Update="Resources\Images\airplane.svg" BaseSize="50,50" />

You could control the size by change to BaseSize=&quot;30,30&quot; or other value. So the Build action of SVG file is MauiImage.

As far as i know we could not change the font size of shell Tabbar. See this thread: How to change Tab title font for TabBar in .NET MAUI. You could also raise an issue on Github.

Hope it works.

英文:

Set the BaseSize of svg file works for me.

You could add the line in csproj file:

&lt;MauiImage Update=&quot;Resources\Images\airplane.svg&quot; BaseSize=&quot;50,50&quot; /&gt;

You could control the size by change to BaseSize=&quot;30,30&quot; or other value. So the Build action of SVG file is MauiImage.

As far as i know we could not change the font size of shell Tabbar. See this thread: How to change Tab title font for TabBar in .NET MAUI. You could also raise an issue on Github.

Hope it works.

huangapple
  • 本文由 发表于 2023年4月4日 13:55:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75925912.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定