图标未在iOS的搜索栏中显示

时间:2019-09-25 09:52:27

标签: react-native react-native-vector-icons

我只是在我的搜索图标应该看到的地方看到一个问号图标。同时为我的其他字体获得无法识别的字体。

  <SearchBar
                round
                containerStyle={{
                    borderTopWidth: 0,
                    borderBottomWidth: 0
                }}
                inputStyle={{ backgroundColor: "white" }}
                inputContainerStyle={{
                    borderRadius: 5,
                    backgroundColor: "white"
                }}
                icon={{
                    type: "fontAwesome",
                    color: "#86939e",
                    name: "fa-search"
                }}
                onSubmitEditing={this.onSubmitEdit}
                searchIcon={{ size: 18 }}
                onChangeText={text => this.SearchFilterFunction(text)}
                onClear={text => this.SearchFilterFunction("")}
                placeholder="Type Here..."
                value={term}
            />

我的Serahc图标没有出现,我无法使用以下字体显示字体:

  menuText: {
    fontSize: 15,
    color: "#fff",
    opacity: 1,
    fontFamily: "lato-regular",
    textTransform: "uppercase"
  }

我已经链接了程序包,并将字体文件复制到了xcode。

我所有的字体都出现在xcode的Resources下。如何显示我的图标?

我的字体在info.plist中:

<key>UIAppFonts</key>
<array>
    <string>Lato-Regular.ttf</string>
    <string>Lato-Light.ttf</string>
    <string>FontAwesome.ttf</string>
    <string>Lato-Bold.ttf</string>
    <string>MaterialIcons.ttf</string>
    <string>Lato-Black.ttf</string>
    <string>Lato-BlackItalic.ttf</string>
    <string>Lato-BoldItalic.ttf</string>
    <string>Lato-Hairline.ttf</string>
    <string>Lato-HairlineItalic.ttf</string>
    <string>Lato-Heavy.ttf</string>
    <string>Lato-HeavyItalic.ttf</string>
    <string>Lato-Italic.ttf</string>
    <string>Lato-LightItalic.ttf</string>
    <string>Lato-Medium.ttf</string>
    <string>Lato-MediumItalic.ttf</string>
    <string>Lato-Semibold.ttf</string>
    <string>Lato-SemiboldItalic.ttf</string>
    <string>Lato-Thin.ttf</string>
    <string>Lato-ThinItalic.ttf</string>
    <string>SpaceMono-Regular.ttf</string>
</array>

2 个答案:

答案 0 :(得分:1)

尝试一下:-

import Icon from 'react-native-vector-icons/FontAwesome';
const myIcon = <Icon name="rocket" size={30} color="#900" />;

在代码中使用myIcon。

答案 1 :(得分:0)

如果您使用的是react-native-vector-icons,请选中此https://oblador.github.io/react-native-vector-icons/以找到您的图标

名称不是 fa-search ,而只是 search