无法在 Xamarin iOS 上使用自定义字体

Mau*_*nas 1 truetype xamarin.ios ios xamarin xamarin.forms

我一直在尝试在 Xamarin iOS 上使用自定义字体,但它根本不起作用。这是我的 info.plist:

    <key>UIAppFonts</key>
<array>
    <string>BebasNeue-Regular.ttf</string>
</array>
Run Code Online (Sandbox Code Playgroud)

我还将 .ttf 文件的构建操作设置为 BundleResource 并“始终复制”,如我已阅读的几个教程中所示。如果我将构建操作更改为“编译”(正如我在其他教程中找到的那样),它将根本无法构建。

编辑:这就是它的使用方式

     <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>
Run Code Online (Sandbox Code Playgroud)

Sus*_*ver 5

在 macOS 应用程序中打开字体Font Book并查看实际名称:

PostScript name BebasNeueRegular
      Full name Bebas Neue Regular
Run Code Online (Sandbox Code Playgroud)

所以,在你的代码中:

<On Platform="iOS" Value="Bebas Neue Regular" />
Run Code Online (Sandbox Code Playgroud)

回复:https ://stackoverflow.com/a/41567423/4984832

回复:https ://stackoverflow.com/a/48191854/4984832

回复:https ://stackoverflow.com/a/36942128/4984832