c# - 在 xamarin.forms 中使用 fontawesome(仅限 iOS 和 Android)

标签 c# xamarin.forms font-awesome

在 xamarin 形式中,使用图标作为 png 文件对于您需要做和验证的所有大小和 native 内容都非常痛苦。我决定使用很棒的字体,但这样我就不能放入工具栏项,也不能放入某些按钮中,也不需要文本。 有没有人有作为文件图像源使用的指南因为 fontimagesource 不兼容用于代替 fileimagesource。或者,任何人都可以使用一些我可以在我所有东西中使用的代码来制作pressEffect 的指南吗?

这不可能

<ContentPage.ToolbarItems>
        <ToolbarItem>
            <ToolbarItem.Icon>
                <FontImageSource/>
            </ToolbarItem.Icon>
        </ToolbarItem>
    </ContentPage.ToolbarItems>

这是它的工作方式
<ContentPage.ToolbarItems>
        <ToolbarItem>
            <ToolbarItem.Icon>
                <FileImageSource/>
            </ToolbarItem.Icon>
        </ToolbarItem>
 </ContentPage.ToolbarItems>

另一种方法是放入标签并与布局一起使用,但它们都没有打印效果

我希望在没有插件的情况下使用打印效果,可能使用简单的渲染,或者至少我想在工具项中使用 fonticon 像普通图像或文本一样。

Obs:工具栏项的文本没有字体族,如果有办法用转换器来做到这一点,我将不胜感激。

最佳答案

现在有了 Xamarin 4.0 新版本,这是可能的。以下代码工作正常:

<Button  Text="Pesquisar">
    <Button.ImageSource>
         <FontImageSource Glyph="&#xf002;" FontFamily="{StaticResource FontIcon}"/>
    </Button.ImageSource>
</Button>

这也是:
<ContentPage.ToolbarItems>
    <ToolbarItem>
        <ToolbarItem.IconImageSource>
             <FontImageSource Glyph="&#xf002;" FontFamily="{StaticResource FontIcon}"/>
        </ToolbarItem.IconImageSource>
    </ToolbarItem>
</ContentPage.ToolbarItems>

关于c# - 在 xamarin.forms 中使用 fontawesome(仅限 iOS 和 Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55494006/

相关文章:

xamarin - Xamarin 中是否有 Canvas 控件的等价物

html - 播放框架 : import Font Awesome does not work

html - Font Awesome CSS 覆盖了我的 CSS

c# - 类库上的公共(public)交通连接管理

c# - API 在 reviews 属性中返回 null

xaml - Xamarin CollectionView 滚动不顺畅

css - 使用CSS在 Font Awesome 图标行之间创建空间

c# - 在转发器控件的元素模板内对齐控件?

c# - 尝试访问事件目录时获取 "The server could not be contacted."

xamarin - 无法使用 token 0100000f 解析类型