【发布时间】:2020-04-10 19:58:14
【问题描述】:
据此贴: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
- NetStandard.Library (2.0.3)
【问题讨论】:
-
“在这篇文章中,我们将了解如何在 Xamarin.Forms 4.5.530 及更高版本中使用它。”
-
那么...那个版本在哪里??????
-
我假设这是一个错字,他的意思是 4.5.0.530 - nuget.org/packages/Xamarin.Forms/4.5.0.530
-
更新到 4.5.0.617 还是一样的问题...奇怪...
-
它在该版本的发行说明中 - docs.microsoft.com/en-us/xamarin/xamarin-forms/release-notes/…。它应该在主 Xamarin.Forms 命名空间中 - 我假设您在文件中有
using Xamarin.Forms;?您可以尝试重启 VS、清除 bin/obj 文件夹等常用技巧
标签: xaml xamarin resources custom-font xamarin.essentials