【发布时间】:2018-09-11 10:59:02
【问题描述】:
我想知道我是否在这里遗漏了一些东西。
当在 iOS 的 xaml 中使用 FontAwesome 时,它可以像这样正常工作:
<Button Text="" HeightRequest="100" BackgroundColor="DarkRed" TextColor="White" FontSize="36">
<Button.FontFamily>
<OnPlatform x:TypeArguments="x:String" Android="fa-regular-400.ttf#Font Awesome 5 Free Regular" iOS="Font Awesome 5 Free" WinPhone="Assets/fa-regular-400.ttf#Font Awesome 5 Free" />
</Button.FontFamily>
</Button>
但是在页面后面的代码中执行此操作时,我没有得到图标,而是得到它的 unicode &#xf075;
这是我的代码背后的代码:
var newBtn = new Button()
{
Text = "",
HeightRequest = 100,
BackgroundColor = Color.DarkRed,
TextColor = Color.White,
FontSize = 36
};
newBtn.FontFamily = Device.RuntimePlatform == Device.iOS ? "Font Awesome 5 Free" : null;
【问题讨论】:
-
试试这个
Text = ((char)0xf11a).ToString(); -
完美,就像 Daniel P 的回答一样。谢谢 :-)
-
问题...如果您有 FA-Pro 的许可证,我该如何使用它?
-
@Mansa- 我从未使用过 FA 许可证。但是,您可以去 FA 支持部门并连同您的查询一起发送邮件给他们。或者在此处或在 xamarin 论坛上提出相同的问题,您可能会得到答案。
标签: xaml xamarin xamarin.forms font-awesome