0

Faced with such a problem.The application was tested on Android. Today I started testing on iOS and an error occurred:

  • fontFamily "Roboto" is not a system font and has not been loaded through Font.loadAsync.

  • If you intended to use a system font, make sure you typed the name correctly and that it is supported by your device operating system.

I can't figure out how to add this font to iOS. I understand that you need to make a custom font. But I don't know where to get them.

Boot Index.js

import {AppRegistry} from 'react-native'
import RootNavigation from './App'
import {name as appName} from './app.json'


AppRegistry.registerComponent(appName, () => RootNavigation)

Then the tabnavigator is loaded:

import React from "react";
import { createBottomTabNavigator } from "react-navigation";
import Ionicons from "react-native-vector-icons/Ionicons";
import Feed from "./src/components/screens/Feed/";
import MapScreen from "./src/components/screens/MapScreen/MapScreen";
import Favorite from "./src/components/screens/Favorite/Favorite";
import Search from "./src/components/screens/Search/Search";
import Profile from "./src/components/screens/Profile/Profile";
import { BLUE } from "./constance";

const RootNavigation = createBottomTabNavigator(
  {
    1: Feed,
    2: MapScreen,
    3: Favorite,
    4: Profile,
    5: Search
  },
  {
    navigationOptions: ({ navigation }) => ({
      tabBarIcon: ({ focused, tintColor }) => {
        const { routeName } = navigation.state;
        let iconName;
        if (routeName === "1") {
          iconName = focused ? "ios-star" : "ios-star";
        } else if (routeName === "2") {
          iconName = focused ? "ios-map" : "ios-map";
        } else if (routeName === "3") {
          iconName = focused ? "ios-paper" : "ios-paper";
        } else if (routeName === "4") {
          iconName = focused ? "ios-person" : "ios-person";
        } else if (routeName === "5") {
          iconName = focused ? "ios-search" : "ios-search";
        }
        return <Ionicons name={iconName} size={22} color={tintColor} />;
      }
    }),
    tabBarOptions: {
      activeTintColor: BLUE,
      inactiveTintColor: "gray",
      inactiveBackgroundColor: "#1f1f1f",
      activeBackgroundColor: "#1f1f1f",
      style: {
        elevation: 30,
        backgroundColor: "green",
        borderTopWidth: 1,
        borderTopColor: "#1f1f1f"
      }
    }
  }
);

export default RootNavigation;

As I understand it somewhere you want to insert:

import { Font } from 'expo';

    state = {
      fontLoaded: false,
    };

    componentDidMount() {
        Font.loadAsync({
          'Roboto': require('./assets/fonts/Roboto.ttf'),
        });
      }

I would be very grateful for your help!

Ilya K
  • 93
  • 8

0 Answers0