简体   繁体   English

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

[英]Use of fontawesome in xamarin.forms (iOS and Android only)

In xamarin forms using icon as png file is very painfull with all the sizeand native stuff that you need to do and verify. 在xamarin表单中,使用图标作为png文件非常麻烦,您需要执行和验证的所有大小和本地内容。 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. 是否有任何人有用作文件图像源的指南,因为fontimagesource与文件图像源的位置不兼容。 Or, anyone has a guide to do presseffect with some code that i can use in all my stuff? 或者, 任何人都可以使用我可以在我的所有东西中使用的某些代码来完成印刷效果?

This is not possible 这是不可能的

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

this is the way it works 这是它的工作方式

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

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. 我希望使用没有插件的新闻效果,或者使用简单的渲染,或者至少我想在工具项目中使用fonticon,例如正常的图像或文本。

Obs: Text of toolbar item dosen't have fontfamily, if there's a way to do this with converter I will be grateful. Obs:工具栏项目的文本没有字体家族,如果有办法用Converter做到这一点,我将不胜感激。

Now with Xamarin 4.0 new release, this it's possible. 现在有了Xamarin 4.0新版本,这是可能的。 The follow code works just fine: 以下代码可以正常工作:

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

And this too: 这也是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM