我在 ContentPage 中使用 FontAwesome,在 Android 和 UWP 中没有任何问题。(Android 使用标签渲染类)。但是,当我用 ContnetPage 替换 NavigationPage 时,UWP 字体图标消失并显示一个正方形!Android 在 NavigationPage 上运行良好。UWP 需要像 Android 一样渲染吗?
public class FontAwesomeIcon : Label
{
public const string Typeface = "FontAwesome";
public FontAwesomeIcon(string fontAwesomeIcon = null)
{
switch (Device.RuntimePlatform)
{
case Device.Windows :
{
FontFamily= "Assets/Fonts/FontAwesome.ttf#FontAwesome";
break;
}
case Device.Android :
{
FontFamily = Typeface;
break;
}
case Device.iOS:
{
FontFamily = Typeface;
break;
}
}
Text = fontAwesomeIcon;
VerticalOptions = LayoutOptions.Center;
}
/// <summary>
/// Get more icons from http://fortawesome.github.io/Font-Awesome/cheatsheet/
/// Tip: Just copy and past the icon picture here to get the icon
/// </summary>
public static class Icon
{
public static string AngleRight = "\uf105";
public static string User = "\uf007";
public static string Lock = "\uf023";
}
}
更新 :
答案是我们必须使用这个FontFamily=@"/Assets/Fonts/FontAwesome.ttf#FontAwesome"