nativescript中分段栏中的图像图标

nativescript中分段栏中的图像图标,nativescript,angular2-nativescript,nativescript-angular,Nativescript,Angular2 Nativescript,Nativescript Angular,如何在nativescript中的分段栏中添加图像图标。你能帮我做这个吗 <SegmentedBar #tabs [selectedIndex]="selectSegment"> <SegmentedBarItem title="test1"></SegmentedBarItem> <SegmentedBarItem title="test2"></SegmentedBarIt

如何在nativescript中的分段栏中添加图像图标。你能帮我做这个吗

 <SegmentedBar #tabs [selectedIndex]="selectSegment">
                <SegmentedBarItem title="test1"></SegmentedBarItem>
                <SegmentedBarItem title="test2"></SegmentedBarItem>
                <SegmentedBarItem title="test3"></SegmentedBarItem>
                <SegmentedBarItem title="test4"></SegmentedBarItem>
        </SegmentedBar>

分段栏没有为每个分段栏指定图像的选项。这是TabView的有效方案。对于SegmentedBar,您只能为整个分割条设置背景图像,该背景图像可用于应用图像模式,但不适用于为不同的分割条应用不同的图标

请看下面的链接


向Nativescript分段条项目添加图标的简单方法是使用FontAwsome(或任何其他图标字体)

1:查看这段()关于如何将FontAwsome安装到{N}应用程序的五分钟短片

2:一旦你安装了图标字体。将
style=“font-family:'fontAwesome'”
属性分配给
SegmentedBar
xml/“html”标记

3:签出以找出要使用的图标的unicode,并将该unicode粘贴到相关
SegmentedBarItem
标记的
title
属性提示:确保代码格式正确。不要复制备忘单上显示的方括号,只复制其中显示的字符串

就这样!您的代码现在应该如下所示:

<SegmentedBar #tabs [selectedIndex]="selectSegment" style="font-family: 'FontAwesome'; color: #eee; background-color: #31394C;">
            <SegmentedBarItem title="&#xf0c0;"></SegmentedBarItem>
            <SegmentedBarItem title="&#xf007;"></SegmentedBarItem>
            <SegmentedBarItem title="&#xf008;"></SegmentedBarItem>
            <SegmentedBarItem title="&#xf0f3;"></SegmentedBarItem>
</SegmentedBar>

此图像:


在android仿真器上显示上述代码的最终结果。

要获得更灵活的方式,您可以创建自定义分段栏并根据需要进行调整。阅读更多