我在ContentPage中使用FontAwesome,在Android和UWP中沒有任何問題。 (Android使用標籤渲染類)。 但是,當我用ContnetPage替換NavigationPage時,UWP字體圖標消失並向我顯示一個正方形! Android與NavigationPage正常工作。 UWP是否需要像Android一樣渲染?如何在NavigationPages UWP Xamarin.Forms中使用FontAwesome圖標?
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";
}
}
更新:
答案是,我們必須在我與ContnetPage取代NavigationPage使用[email protected]"/Assets/Fonts/FontAwesome.ttf#FontAwesome"
他們兩個都不能在NavigationPage上工作。 我使用「FontAwesome.ttf」,因爲我的字體文件是「FontAwesome.ttf」在資產/ Fonts文件夾... –
我發現我的答案。不管怎樣,謝謝你。 –
您能否與我分享解決方案?所以來過這個問題的其他用戶可以參考。 –