在NavigationButton上使用自定义图标的本机脚本 [英] Nativescript using custom icons on NavigationButton
问题描述
我正在尝试在NativeScript Angular应用程序的ActionBar上添加带有自定义字体的按钮.这是我到目前为止尝试过的:
I'm trying to add a button with custom fonts on the ActionBar on a NativeScript Angular app. This is what I tried so far:
<ActionBar class="cp-icon">
<NavigationButton text="" (tap)="goBack()"></NavigationButton>
<Image src="res://logo_h_white"></Image>
</ActionBar>
// Or one of these optio
<ActionItem text="" (tap)="goBack()"></ActionItem>
<Label text=""></Label>
<Button text=""></Button>
但是它们似乎都不起作用.我确实安装了字体,因为可以在视图中使用它.另外,如果我只是将text属性更改为字符串而不是图标,它也不会显示任何内容.
But none of them seems to be working. I do have the font instaled because I can use in the view. Also, if I just change the text attribute to be a string instead of an icon, it also doesn't show nothing.
有没有办法做到这一点?
Is there a way to do this?
推荐答案
您最好的选择是使用nativescript-ngx-fonticon插件:
Your best bet is using the nativescript-ngx-fonticon plugin: https://github.com/NathanWalker/nativescript-ngx-fonticon
还通过检查以下SO答案来避免一些常见的问题: https://stackoverflow.com/a/41861624/2596974
Avoid a few common pitfals by also checking this SO answer: https://stackoverflow.com/a/41861624/2596974
这篇关于在NavigationButton上使用自定义图标的本机脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!