gpt4 book ai didi

xaml - Xamarin FontAwesome 无法从背后的代码中工作

转载 作者:行者123 更新时间:2023-12-03 20:29:35 24 4
gpt4 key购买 nike

我想知道我是否在这里遗漏了一些东西。

在 iOS 的 xaml 中使用 FontAwesome 时,它​​的工作原理如下:

<Button Text="&#xf075;" 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 = "&#xf11a;",
HeightRequest = 100,
BackgroundColor = Color.DarkRed,
TextColor = Color.White,
FontSize = 36

};

newBtn.FontFamily = Device.RuntimePlatform == Device.iOS ? "Font Awesome 5 Free" : null;

最佳答案

在 C# 代码中使用时,您必须像这样使用它:
Text = "\uf11a"

关于xaml - Xamarin FontAwesome 无法从背后的代码中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52274361/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com