NativeScript: Icon fonts not working for TabView tabs title on iOS

Please, provide the details below:

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Yes, looked for similar issues and solution. Looked at: https://github.com/NativeScript/NativeScript/issues/1217 and https://github.com/NativeScript/nativescript-angular/issues/364

Tell us about the problem

Not able to display icon fonts on TabView tabs title on iOS after updating to NS 3.0 using Typescript(No Angular). Icon fonts are working fine in Android tabview.

Which platform(s) does your issue occur on?

iOS

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.0.2
  • Cross-platform modules: (check the ‘version’ attribute in the node_modules/tns-core-modules/package.json file in your project)
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)
  • Plugin(s): (look for the version number in the package.json file of your project) ┌──────────────────┬─────────────────┬ │ Component │ Current version │ Latest version │ Information │ │ nativescript │ 3.0.2 │ 3.0.2 │ Up to date │ │ tns-core-modules │ 3.0.1 │ 3.0.1 │ Up to date │ │ tns-android │ 3.0.1 │ 3.0.1 │ Up to date │ │ tns-ios │ 3.0.1 │ 3.0.1 │ Up to date │ └──────────────────┴─────────────────┴

Please tell us how to recreate the issue in as much detail as possible.

Create a TabView and in TabViewItem set title to use an icon font (using FontAwesome in my case). You can use the sample codes below:

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
    <Page.actionBar>
        <ActionBar title="Icon Font Test" icon="" class="action-bar">
        </ActionBar>
    </Page.actionBar>
    <TabView tabTextColor="red" androidSelectedTabHighlightColor="red" selectedTabTextColor="green" loaded="mainContentLoaded" id="tabView1">
         <TabView.items>
            <TabViewItem title="&#xf003; All" class="mati">
              <TabViewItem.view>
                <Label horizontalAlignment="center" text="&#xf003;" class="mati"/>
              </TabViewItem.view>
            </TabViewItem>
            <TabViewItem title="&#xf0a2; Notifications" class="mati">
              <TabViewItem.view>
                <Label horizontalAlignment="center" text="&#xf0a2;" class="mati"/>
              </TabViewItem.view>
            </TabViewItem>
            <TabViewItem title="&#xf044; Requests" class="mati">
              <TabViewItem.view>
                <Label horizontalAlignment="center" text="&#xf044;" class="mati"/>
              </TabViewItem.view>
            </TabViewItem>
          </TabView.items>
    </TabView>
</Page>
.btn {
    font-size: 18;
}
 
.mati {
    font-family: fontawesome, FontAwesome;
}

Images for reference:

on iOS screen shot 2017-06-01 at 10 24 54 am on Android tns-nativescriptactivity-06012017102104

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

@tsonevn I can confirm that in 3.3 it works properly, I think that it was even working earlier, though it was not that evident that the class “icon” (or whatever icon class) was meant to be applied on the TabView element, not on the StackLayout.

The only issue I’m having now is that applying the class to the TabView applies to font-family to each component inside the TabView, which is somehow replacing some text with some icons, not sure if that’s intended though.

Thanks again for the support!

Hi @briosheje, I tested the scenario with the icon font and its usage inside the TabView and everything seems to work as expected. In my sample code, I used icomoon font. For your convenience, I am attaching sample code.

HTML

<TabView class="icon" selectedIndex="0"  (selectedIndexChange)="onIndexChanged($event)" sdkExampleTitle sdkToggleNavButton>
	<StackLayout *tabItem="{title: '&#xea90;'}">
		<Label text="NativeScript" class="m-15 h2 text-left" color="blue"></Label>
		<ScrollView>
			<Label [text]="content" textWrap="true" class="m-15"></Label>
		</ScrollView>
	</StackLayout>
	<StackLayout *tabItem="{title: 'Icon'}">
		<Label text="&#xea90;" textWrap="true"></Label>
		
		<Image class="m-t-30 m-b-15" src="res://icon" width="80" height="80"></Image>
		<Label text="NativeScript" textWrap="true" class="h2 m-x-auto" color="blue"></Label>
	</StackLayout>
</TabView>

screen shot 2017-11-02 at 4 22 27 pm a6010lrx22gntsonev11022017162253