在 xamarin.forms 中使用 fontawesome(仅限 iOS 和 Android) [英] Use of fontawesome in xamarin.forms (iOS and Android only)

查看:21
本文介绍了在 xamarin.forms 中使用 fontawesome(仅限 iOS 和 Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In xamarin forms using icon as png file is very painfull with all the sizeand native stuff that you need to do and verify. I decide to use font awesome but this way i can't put in toolbar item and neither in some button tha need a text too. Do anyone has a guide to use as fileimagesource because the fontimagesource is not compatible to use in place of fileimagesource. Or, anyone has a guide to do presseffect with some code that i can use in all my stuff?

这是不可能的

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

这就是它的工作方式

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

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

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

Other way was to put in label and use with layouts but both of them dosen't have the press effect

I expect to use the press effect without plugin, using a easy render maybe, or at least i want to use fonticon in toolber item like a normal image or text.

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

Obs: Text of toolbar item dosen't have fontfamily, if there's a way to do this with converter I will be grateful.

推荐答案

现在有了 Xamarin 4.0 新版本,这成为可能.以下代码工作正常:

Now with Xamarin 4.0 new release, this it's possible. The follow code works just fine:

<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>

这篇关于在 xamarin.forms 中使用 fontawesome(仅限 iOS 和 Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆