在xamarin.forms中使用fontawesome(仅适用于iOS和Android) [英] Use of fontawesome in xamarin.forms (iOS and Android only)
问题描述
在xamarin表单中,使用图标作为png文件非常痛苦,需要执行和验证的所有大小和本机内容.我决定使用很棒的字体,但是这样我就不能放在工具栏项中,也不能在某些按钮中也需要文本. 任何人都有用作文件图像源的指南,因为fontimagesource与文件图像源不兼容.或者,有人指导我用我可以在所有东西中使用的某些代码来产生效果吗?
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: 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="" FontFamily="{StaticResource FontIcon}"/>
</Button.ImageSource>
</Button>
这也是:
<ContentPage.ToolbarItems>
<ToolbarItem>
<ToolbarItem.IconImageSource>
<FontImageSource Glyph="" FontFamily="{StaticResource FontIcon}"/>
</ToolbarItem.IconImageSource>
</ToolbarItem>
</ContentPage.ToolbarItems>
这篇关于在xamarin.forms中使用fontawesome(仅适用于iOS和Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!