问题描述
我一直在尝试在 Xamarin iOS 上使用自定义字体,但它根本不起作用.这是我的 info.plist:
I've been trying to use a custom font on Xamarin iOS but it simply does not work. This is my info.plist:
<key>UIAppFonts</key>
<array>
<string>BebasNeue-Regular.ttf</string>
</array>
我还将 .ttf 文件的构建操作设置为 BundleResource 并始终复制",如我已阅读的几个教程所示.如果我将构建操作更改为编译(正如我在其他教程中发现的那样),它就不会构建.
I also set the build action of the .ttf file to BundleResource and "always copy" as shown on several tutorials I already read. If I change the build action to Compile (as I found on other tutorials), it will simply not build.
这就是它的使用方式
<Label Text="Hello Forms with XAML">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<On Platform="iOS" Value="BebasNeue-Regular" />
<On Platform="Android" Value="BebasNeue-Regular.ttf#BebasNeue-Regular" />
</OnPlatform>
</Label.FontFamily>
推荐答案
在 macOS Font Book
应用中打开字体并查看实际名称:
Open the font in the macOS Font Book
app and review the actual name:
PostScript name BebasNeueRegular
Full name Bebas Neue Regular
因此,在您的代码中:
<On Platform="iOS" Value="Bebas Neue Regular" />
回复:https://stackoverflow.com/a/41567423/4984832
回复:https://stackoverflow.com/a/48191854/4984832
回复:https://stackoverflow.com/a/36942128/4984832
这篇关于无法在 Xamarin iOS 上使用自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!