1

根据这篇文章:https ://devblogs.microsoft.com/xamarin/embedded-fonts-xamarin-forms/

添加自定义字体的新方法是将字体添加为 EmbeddedResource,然后在 App.xaml.ca 中添加以下行:

[assembly: ExportFont("DSEG7ModernRegular.ttf")]

但我得到这个错误:

Error   CS0246  The type or namespace name 'ExportFontAttribute' could not be found (are you missing a using directive or an assembly reference?)

我的项目参考:

  • Xamarin.Essentials (1.3.1)
  • Xamarin.Forms (4.4.0.991265) - 4.5
  • 网络标准库 (2.0.3)
4

1 回答 1

2

ExportFontAttributeXamarin.Forms命名空间中,所以请确保你有

using Xamarin.Forms;
于 2020-04-10T21:32:16.257 回答