Xamarin自定义字体在预览中显示,但在构建中不显示

时间:2018-09-12 06:25:47

标签: c# ios xamarin font-awesome

我在这里有点挣扎。我正在尝试让FontAwesome在我的iOS应用程序中工作,我想我真的很近(但没有雪茄)。

在Visual Studio预览窗口(iOS)中查看我的项目时,一切看起来都应该看起来像,我可以看到fa图标,但是当构建至电话或模拟器时,我会看到带有“?”的正方形内部:-/

这是我尝试实现的方法:

var thisBtn = new Button()
{
    HeightRequest = 60,
    WidthRequest = 60,
    Text = "\uf007",
    FontSize = 60,
    HorizontalOptions = LayoutOptions.Center,
    VerticalOptions = LayoutOptions.End,
    Margin = new Thickness(0, 0, 0, 0),
    TextColor = Color.FromHex("#204353")
};

thisBtn.FontFamily = Device.RuntimePlatform == Device.iOS ? "FontAwesome5ProLight" : null;

我已经在我的info.plist中包括了这样的字体:

<key>UIAppFonts</key>
<array>
    <string>FontAwesome.ttf</string>
    <string>fa-brands-400.ttf</string>
    <string>fa-light-300.ttf</string>
    <string>fa-solid-900.ttf</string>
    <string>fa-regular-400.ttf</string>
</array>

我真的很困惑,我希望得到帮助:-)

1 个答案:

答案 0 :(得分:0)

请更新fontaswesome.tff的路径位置,并检查其根目录或正确的目录。 一些字典路径在手机或模拟器中不可接受。请检查一下。