FlyoutItem
有什么方法可以更改Xamarin Forms中内容的字体系列Shell
吗?
我已经.ttf
在共享项目中添加了自定义字体作为嵌入式资源,并且还使用文件AssemblyInfo.cs
.
任何帮助,将不胜感激。
FlyoutItem
有什么方法可以更改Xamarin Forms中内容的字体系列Shell
吗?
我已经.ttf
在共享项目中添加了自定义字体作为嵌入式资源,并且还使用文件AssemblyInfo.cs
.
任何帮助,将不胜感激。
对于Shell
弹出内容(弹出项 + 菜单项),您可以使用带有FlyoutItemLabelStyle
类的样式:
<Style ApplyToDerivedTypes="True" Class="FlyoutItemLabelStyle" TargetType="Label">
<Setter Property="FontFamily" Value="YourFontExportName"/>
</Style>
来自文档样式 FlyoutItem 和 MenuItem 对象。
就像 Cfun 说的那样,您可以将 Shell Flyout 项目字体设置为FlyoutItemLabelStyle
.
将字体作为嵌入资源 ( Build Action: EmbeddedResource
) 添加到 Xamarin.Forms 共享项目。
使用 ExportFont 属性在 AssemblyInfo.cs 等文件中向程序集注册字体文件。也可以指定一个可选的别名。
AssemblyInfo.cs
:
[assembly: ExportFont("Trashtalk.ttf", Alias = "Trashtalk")]
以您的风格添加此字体。
<Style Class="FlyoutItemLabelStyle" TargetType="Label">
<Setter Property="FontFamily" Value="Trashtalk" />
</Style>
截屏: